Error_messages_for question

a question about error_messages_for:

when i retrieve the error messages the error_messages_for display a list
errors with the name of input followed the customizable string error.

But if i want to change the name of input on the error message how can i
do?
imagine for example i need to translate the errors messages in various
languages…

You just need to use rails’ built-in i18n feature.

Drop a en.yml in config/locales with content like this:

en:
activerecord:
models:
user: “User”
attributes:
user:
login: “user name”
errors:
messages:
blank: ‘should not be blank’


in model:
validates_presence_of :login


in environment.rb:
config.i18n.default_locale = :en

Then if the user doesn’t enter a user name for the login field, the
error message will be like this:
user name should not be blank


James
http://ashchan.com

On Sep 14, 10:11 pm, Aldo I. [email protected]

and if i don’t use an activerecord model?
thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs