I want to get the message from the errors array for a field.
Example for the password field:
@user.errors.select{|key,msg| key == :password}
This produces:
{:password=>["Your password and confirmation are not the same"]}
What I want is a way to just get the message for the field.
How can I do this?
Just use
@user.errors[:password]Alternatively you can use one of the following methods
edit:
Using the values method you could do this
It depends on what you need. Keep in mind that any
errorsvalue is an array itself because a form field could have more than one error. Try it yourself with rails console