Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

weird behavior on error_messages_for

#3629

I'm not sure if it is a bug, but it causes a weird behavior.

In these lines
error_messages_for in Rails 2.3.5 the gsub call force you to have a locale file with models like that:

models:
  bank account:
    one: "conta"
    other: "contas"

Instead of

models:
  bank_account:
    one: "conta"
    other: "contas"

And when you call something like BankAccount.human_name it will returns "Bankaccount" instead of "conta".

Reported by Daniel Lopes · December 29th, 2009 @ 07:53 PM

State: resolved
Milestone: 2.3.6
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Martin Andert
    Martin Andert

    I am experiencing the same problem. Looks as error_messages_for does a gsub('_', ' ') on the object name before handing it to i18n. My current workaround:

    de:
      active_record:
        models:
          back_account: "Bankkonto"
          back account: "Bankkonto"
    

    So both BankAccount.human_name and error_messages_for :bank_account return the same translated model name.

    February 16th, 2010 @ 01:00 PM

  2. Martin Andert
    Martin Andert
    • Tag changed from 2.3.5 to 2.3.5, error_messages_for, i18n

    February 16th, 2010 @ 01:02 PM

  3. José Valim
    José Valim
    • Assigned user set to José Valim
    • Milestone set to 2.3.6

    Could you please provide a failing test case?

    February 16th, 2010 @ 11:26 PM

  4. Martin Andert
    Martin Andert
    • Tag changed from 2.3.5, error_messages_for, i18n to 18, 2, error_messages_for

    I have attached a failing test case.

    February 17th, 2010 @ 01:56 PM

  5. Martin Andert
    Martin Andert

    And here is the test case and the fix in one patch.

    February 17th, 2010 @ 01:57 PM

  6. Repository
  7. José Valim
    José Valim
    • State changed from new to resolved

    Awesome! Just applied.

    February 17th, 2010 @ 08:08 PM

  8. Andrea Campi
    Andrea Campi
    • Tag changed from 18, 2, error_messages_for to 2, error_messages_for
    • Importance changed from to Low

    October 10th, 2010 @ 11:43 PM

  9. Andrea Campi
    Andrea Campi
    • Tag changed from 2, error_messages_for to 2-3-stable, error_messages_for

    October 16th, 2010 @ 11:36 PM