共享Active Record属性转换的最佳实践

时间:2015-06-04 10:49:25

标签: ruby-on-rails activerecord internationalization yaml rails-activerecord

我的翻译文件中有以下yaml:

se:
  activerecord:
    attributes:
      user:
        name: "Namn"
        town: "Stad"
      admin:
        name: "Namn"
        level: "Nivå"
      pet:
        name: "Namn"
      company:
        name: "Namn"
      food:
        name: "Namn"

我有办法干这个并在所有模特中分享name的翻译吗?如果我可以完全删除petcompanyfood的条目,则可获得奖励积分。

1 个答案:

答案 0 :(得分:1)

se:
  common: &common
    name: "Namn"
  activerecord:
    attributes:
      user:
        <<: *common
        town: "Stad"
      admin:
        <<: *common
        level: "Nivå"
      pet:
        <<: *common
      company:
        <<: *common
      food:
        <<: *common