[ ActiveModel ] errors.full_message

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

person = Person.create(address: '123 First St.')
person.errors.full_messages
# => ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Email can't be blank"]

Adding your own error messages

errors.add(:name, "cannot be nil")

ref : http://apidock.com/rails/ActiveModel/Errors/full_messages,

http://apidock.com/rails/ActiveModel/Errors

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s