The I18n scopes provided by the Rails Guide are specific to utilization of ActiveModel::Validations
within ActiveRecord
objects. For example:
en:
activerecord:
errors:
models:
some_model:
attributes:
name:
blank: "Please enter your full legal name."
This won't work when using ActiveModel::Validations
in this way:
class SomeModel
include ActiveModel::Validations
validates :name, presence: true
end
Instead the framework default “can't be blank" is used.
How can this be resolved?
Substituting activemodel
for activerecord
fixes this and allows all subsequent scopes to work. Example:
en:
activemodel: # <---
errors:
models:
message:
attributes:
name:
blank: "Please enter your name."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.