Re: errors.add, setting the whole message

Max Williams
Tue, 12 Oct 2010 15:42:49 -0000

Sjoerd Andringa wrote in post #943536:

> 2. Override the default error message for this kind of error on this
> particular attribute (Also see documentation for
> http://apidock.com/rails/ActiveRecord/Error/generate_full_message):
>
> In app_root/config/locales/en.yml:
>
> en:
>     activerecord:
>         errors:
>             full_messages:
>                 job_role_id_short:
>                     blank: "Job cannot be blank"

Thanks Sjoerd but i can''t get this working: i put this in my
config/locales/en.yml file:

en:
...
...
  activerecord:
    errors:
      full_messages:
        password:
          blank: "Something about the password being missing"
          invalid: "Something about the password not being valid"

Then in my controller, i do

      @user_session.errors.add(:password) #use default of :invalid

And i get "Password is invalid" back.  This is in rails 2.3.4.

thanks, max