1

我有这个模型

class Oferta < ActiveRecord::Base
  belongs_to :entidade
  has_many :candidatos, :through => :interesses
  has_many :interesses, foreign_key: "oferta_id", dependent: :destroy

基本上我有这个模型和模型Interesse以及它的复数形式,interesses但我认为 Rails 实际上在最后起飞 es并留给我兴趣。现在它给了我这个错误:

uninitialized constant Oferta::Interess

我如何定义单数 tointeressesinteresse?并不是interess

4

1 回答 1

11

config/initializers/inflections.rb你可以在你的文件中做这样的事情。

ActiveSupport::Inflector.inflections do |inflect|
 inflect.irregular 'interesse', 'interesses'
end
于 2014-08-28T08:54:36.683 回答