1

I started working with Devise. Quite an awesome gem. Reading through a neat exchange I was able to do a lot of interesting message customization.

NOW though, I'm running into an intriguing issue with customizing error messages based on noun gender for I18N purposes. Here, I have an error message containing %{resource}, where resource will sub in my model name (user). In French, the word coming before the %{resource} will vary depending on gender. Is there a way for me to branch out to a particular error message based on the %{resource} gender?

Community
  • 1
  • 1
sybohy
  • 1,856
  • 2
  • 20
  • 25

1 Answers1

1

You can customize the human-readable model name by implementing the model_name instance method in your user model.

http://api.rubyonrails.org/classes/ActiveModel/Naming.html

The model_name method has to return an object of type ActiveModel::Name

http://api.rubyonrails.org/classes/ActiveModel/Name.html

You can customize this object to fit your i18n needs.

M. Cypher
  • 6,966
  • 2
  • 34
  • 34