Ruby on Rails: How do you explicitly define plural names and singular names in Rails?

后端 未结 3 1795
故里飘歌
故里飘歌 2020-12-04 21:00

For example, I\'m using \"Bonus\" as my model, so I\'d expect \"bonuses\" to be the plural form and \"bonus\" to be the singular form.

However, in Ruby, this results

3条回答
  •  一个人的身影
    2020-12-04 21:37

    I believe you use the Inflector in your environment.rb (memory's a bit sketchy though) If I remember correctly you put it in a block

    Inflector.inflections { | i | i.irregular 'bonus', 'bonuses' }
    

提交回复
热议问题