1

I have this model

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

basically I have this model and model Interesse and its plural its interesses but I think Rails is actually taking off the es at the end and leaving me with Interess. And now it gives me this error:

uninitialized constant Oferta::Interess

How can I define that the singular to interesses is interesse? and not interess

João Cunha
  • 9,929
  • 4
  • 40
  • 61

1 Answers1

11

You can do something like this in your config/initializers/inflections.rb file.

ActiveSupport::Inflector.inflections do |inflect|
 inflect.irregular 'interesse', 'interesses'
end
Serdar Dogruyol
  • 5,147
  • 3
  • 24
  • 32