2014-08-28 3 views
1

의 복수의 이름을 정의 나는이 모델 기본적으로루비 - 모델 또는 표

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

나는이 모델 및 모델 Interesse과 복수가에게이 그 interesses하지만 난 레일 실제로에서 es을 이륙 생각 끝내고 나에게 Interess를 남겨주세요. 그리고 지금은 날이 오류를 제공합니다

uninitialized constant Oferta::Interess 

어떻게 interesses에 단수가 interesse이라고 정의 할 수있다? 아니요 interess

+1

는 http://stackoverflow.com/questions/1185035/how-do-i-override-rails-naming-conventions –

+0

유용한 링크를 참조하십시오. 감사! – Lokuzt

답변

10

config/initializers/inflections.rb 파일에서 이와 같은 작업을 수행 할 수 있습니다.

ActiveSupport::Inflector.inflections do |inflect| 
inflect.irregular 'interesse', 'interesses' 
end 
+0

예. 나는 위의 링크를 보았다. 하지만 그래, 그게 내가 한 짓이야. 답변 해주셔서 감사합니다. 내가 할 수있는 한 빨리 받아 들일거야 – Lokuzt

+0

Rails 3.0의 편집보기 + –

+4

위의 링크를 기반으로 사용자 정의 굴곡은 'config/initializers/inflections.rb'에 있어야합니다. – Rahul