Reputation: 10551
Now, I'm not really sure what data structure this is...it seems to be a hash of two named hashes, @base and @messages.
#<ActiveModel::Errors:0x00000103a9cc80 @base=#<User id: nil, first_name: "Jimmy", last_name: "Thehat", profile_name: "Jimbohatboy", email: "awesomedog@hotmail.co.uk", encrypted_password: "$2a$04$MX40ryz4CU2jRuE4Pfy5.eRUz3rRZkmsvw7FXQyE6Bj1...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, confirmation_token: nil, confirmed_at: nil, confirmation_sent_at: nil, unconfirmed_email: nil, failed_attempts: 0, unlock_token: nil, locked_at: nil, created_at: nil, updated_at: nil>, @messages={}>
I know how to print the data in a keyed entry, but not with this. How could I iterate over the @messages hash?
Upvotes: 1
Views: 79
Reputation: 107107
It is a ActiveModel::Errors object (as it says). Find a list of methods here: http://api.rubyonrails.org/classes/ActiveModel/Errors.html
For example:
obj.full_messages.each { |error| puts error }
Upvotes: 1