I18n rollback in attributes

How to use reserve for very often used attr_names like title and created_at ?

How it usually works:

 activerecord.attributes.[model_name].attr_name 

I want to do something like this:

 activerecord.attributes.defaults.attr_name 

There are so many examples of how to do this to massage errors, but for simple attributes, no :( http://guides.rubyonrails.org/v2.3.8/i18n.html#translations-for-active-record-models p>

+4
source share
1 answer

Here is a file containing a method that processes translations (human_attribute_name). I think that by seeing this, you can simply do in your lang.yml , for example:

 attributes: username: "Nickname" 

instead:

 attributes: user: username: "Nickname" 

And it should work for all models!

+7
source

Source: https://habr.com/ru/post/1394756/


All Articles