文件名称:strip_attributes:ActiveModel扩展,可在验证之前自动剥离开头和结尾空格的所有属性。 如果属性为空白,则将值剥离为nil
文件大小:18KB
文件格式:ZIP
更新时间:2024-02-26 09:32:49
ruby rails activerecord rubygem activemodel
StripAttributes StripAttributes是一个ActiveModel扩展,可在验证之前自动剥离开头和结尾空白的所有属性。 如果属性为空,则默认情况下会将值剥离为nil 。 它通过向记录添加一个before_validation钩子来工作。 默认情况下,所有属性都被去除空格,但是:only和:except选项可用于限制去除哪些属性。 这两个选项都接受一个属性( only: :field )或属性数组( except: [:field1, :field2, :field3]除外)。 也可以使用:if和:unless选项跳过每个模型的所有属性。 安装 在您的Gemfile
【文件预览】:
strip_attributes-master
----.gitignore(68B)
----README.md(7KB)
----gemfiles()
--------activemodel-6.1.gemfile(82B)
--------activemodel-3.2.gemfile(195B)
--------activemodel-main.gemfile(109B)
--------activemodel-6.0.gemfile(82B)
--------activemodel-5.2.gemfile(82B)
--------activemodel-4.2.gemfile(82B)
----CHANGELOG.md(74B)
----.github()
--------no-response.yml(704B)
--------workflows()
--------FUNDING.yml(453B)
----test()
--------strip_attributes_test.rb(13KB)
--------test_helper.rb(673B)
--------matchers_test.rb(3KB)
----Gemfile(100B)
----Guardfile(198B)
----strip_attributes.gemspec(1KB)
----CONTRIBUTING.md(1KB)
----LICENSE.txt(1KB)
----lib()
--------strip_attributes()
--------strip_attributes.rb(3KB)
----Rakefile(229B)