3

I have a simple internationalization:

attributes:
  user:
    login: Login
errors:
  template:
    header: "Errors"
    body: ""
  models:
    user:
      attributes:
       login:
         taken: "The chosen {{attribute}} is already registered"

The resulting error message is as follows:

Login The chosen Login is already registered

It seems, like Rails automatically prepends the error messsage with attribute name. This forces me to arrange messages in only one way - with attribute name as a first word.

I need the following error message:

The chosen Login is already registered

How can I configure Rails to not prepend the error message with the attribute name?

John Topley
  • 113,588
  • 46
  • 195
  • 237
AntonAL
  • 16,692
  • 21
  • 80
  • 114
  • 1
    I won't mark your question as a duplicate because it is slightly different due to the use of internationalisation, but see my previous answer to the following question to see if that helps you: [remove field name from object validation message](http://stackoverflow.com/questions/2951333/remove-field-name-from-object-validation-message/2951461#2951461) – mikej Jul 30 '10 at 13:44
  • Actually, that's about to help me out, for a similar question that now won't have to be asked. – NinjaCat Jul 31 '10 at 16:37

1 Answers1

13

You need to specify the error message format in order to remove the model name. I believe this is only possible as of Rails 3.2.6 and up. There are more details on the I18n chapter in Rails Guides.

en:
  errors:
    format: "%{message}"

The default is %{attribute} %{message}.

Mohamad
  • 34,731
  • 32
  • 140
  • 219