Amja
Amja

Reputation: 1387

Rails I18n Pluralization Error

I wanted to set a custom error message for when an email was already taken so I edited the config/locales/en.yml file. It looked like this:

en:
  activerecord:
    models:
      user:
        email:
          taken: "already being used"

When I submit the form with email in it, I get this error:

translation data {:email=>{:taken=>"already being used"}} can not be used with :count => 1

I've only just started looking into i18n so this may be a really simple mistake but I can't find an answer.

Upvotes: 0

Views: 205

Answers (1)

cortex
cortex

Reputation: 5206

Try:

en:
  activerecord:
    errors:
      models:
        user:
          attributes:
            email:
              taken: "already being used"

See section 5.1.1 in Rails Guide.

Hope this helps!

Upvotes: 2

Related Questions