Flowdock
method

messages_for

Importance_1
Ruby on Rails latest stable (v6.1.7.7) - 0 notes - Class: ActiveModel::Errors
messages_for(attribute) public

Returns all the error messages for a given attribute in an array.

class Person
  validates_presence_of :name, :email
  validates_length_of :name, in: 5..30
end

person = Person.create()
person.errors.messages_for(:name)
# => ["is too short (minimum is 5 characters)", "can't be blank"]
Show source
Register or log in to add new notes.