It finds an error message in the namespace chain. Consider a user model with a name attribute check as follows:
class User < ActiveRecord::Base validates :name, presence: true end
The key for reporting an error in this case is: blank. Active Record will look for this key in namespaces:
activerecord.errors.models.[model_name].attributes.[attribute_name] activerecord.errors.models.[model_name] activerecord.errors.messages errors.attributes.[attribute_name] errors.messages
Thus, in our example, he will try the following keys in this order and return the first result:
activerecord.errors.models.user.attributes.name.blank activerecord.errors.models.user.blank activerecord.errors.messages.blank errors.attributes.name.blank errors.messages.blank
Hope this helps. Thanks
source share