Ruby on rails i18n属性中的回退
如何为经常使用的Ruby on rails i18n属性中的回退,ruby-on-rails,internationalization,Ruby On Rails,Internationalization,如何为经常使用的attr\u名称使用回退,如标题和在创建的名称 它通常的工作原理: activerecord.attributes.[model_name].attr_name 我想做这样的事情: activerecord.attributes.defaults.attr_name 关于如何处理错误消息,有很多例子,但对于普通属性,没有一个例子:(是包含处理翻译的方法的文件(human\u attribute\u name)。我认为,看到这一点,您可以在lang.yml中执行,例如: att
attr\u名称
使用回退,如标题
和在
创建的名称
它通常的工作原理:
activerecord.attributes.[model_name].attr_name
我想做这样的事情:
activerecord.attributes.defaults.attr_name
关于如何处理错误消息,有很多例子,但对于普通属性,没有一个例子:(是包含处理翻译的方法的文件(human\u attribute\u name)。我认为,看到这一点,您可以在lang.yml
中执行,例如:
attributes:
username: "Nickname"
而不是:
attributes:
user:
username: "Nickname"
而且它应该适用于所有模型!谢谢!路径是
attributes.attr\u name
noactiverecord
出于某种原因:因为现在您可以使用没有数据库的模型(因此没有activerecord),这就是activemodel。