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

后端 未结 3 1796
故里飘歌
故里飘歌 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:43

    In config/initializers, you will find a file called inflections.rb. There are some instructions in here, but you will want something along the lines of:

    ActiveSupport::Inflector.inflections do |inflect|
      inflect.irregular 'bonus', 'bonuses'
    end
    

提交回复
热议问题