`
ZoOL
  • 浏览: 29957 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

I18n的human_attribute_name方法

阅读更多

当使用I18n配置mode时, 可以用yml配置'zh-CN':

  activerecord:
    models:
      user: "用户"
    attributes:
      user:
        username: "用户名"
        email: "邮箱"
        password: "密码"

 

因此在form_for里的

 

f.label :username

 

便会自动转化为 用户名

 

那在其他views要使用I18n呢? 很简单, 使用  User.human_attribute_name(:username), 就可以获得  用户名 

2
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics