1

Default ActiveModel::Errors are great, but i am solving problem, that the messages are anonymous. For example there is message should look like an email address. that belongs to email field, but what i want is to know that this error message is format type. And the other message doesn't match confirmation is confirmation type.

#<ActiveModel::Errors:0x000001054abef0 @base=#<User ... >, 
    @messages={
        :password=>["doesn't match confirmation"], 
        :email=>["should look like an email address."]}>

Is there any gem for better errors, or do any of you have idea of monkey patch?

Thanks

Schovi
  • 1,960
  • 5
  • 19
  • 33
  • Have a look at this question: http://stackoverflow.com/questions/3671098/better-way-to-access-individual-rails-activerecord-error – Martin Svalin Oct 03 '11 at 09:17

1 Answers1

0

In rails validations, you can add custom messages to be passed up the exception food chain, generated from the model.

ActiveRecord validations

  • I know that :) But it is not exactly what I want. I want to recognize in Error object which message belongs to which type of validation and use it for example with javascripts validations. – Schovi Jul 26 '11 at 13:46