Use string-based fields. [ci skip]

This commit is contained in:
Cassidy Kobewka 2018-04-16 19:09:45 -04:00
parent 2aa8e0a56f
commit 3137a8739e
No known key found for this signature in database
GPG Key ID: 256CDBF985F0BFBE
2 changed files with 5 additions and 5 deletions

View File

@ -63,7 +63,7 @@ module ActiveModel
# and strings in shortcut form.
#
# validates :email, format: /@/
# validates :subscribed_to_newsletter, inclusion: [true, false]
# validates :role, inclusion: %(admin contributor)
# validates :password, length: 6..20
#
# When using shortcut form, ranges and arrays are passed to your

View File

@ -857,12 +857,12 @@ In the event you need to access nested attributes within a given model, you shou
en:
activerecord:
attributes:
user/subscribed_to_newsletter:
true: "True"
false: "False"
user/role:
admin: "Admin"
contributor: "Contributor"
```
Then `User.human_attribute_name("subscribed_to_newsletter.true")` will return "True".
Then `User.human_attribute_name("role.admin")` will return "Admin".
NOTE: If you are using a class which includes `ActiveModel` and does not inherit from `ActiveRecord::Base`, replace `activerecord` with `activemodel` in the above key paths.