我使用has_many :through
由具有三種模式的關係:HAS_MANY:通過關聯
class Curriculum class < ActiveRecord::Base
has_many :interests
has_many :vacancies,: through => :interests
end
class Vacancy class < ActiveRecord::Base
has_many :interests
has_many :resumes,: through => :interests
end
class Interest < ActiveRecord:: Base
belongs_to :vacancy
belongs_to :curriculum
end
並創建課程和空缺,我通過行政創建它們,我需要知道我怎樣才能創建感興趣空缺的ID,以及如何登錄系統,我必須得到它的ID,並建立新的銀行利益關係。我想知道如何編程來做到這一點,我想知道控制器將如何獲得創建操作,以及有什麼更好的方法來做到這一點。
我忘了上面的評論,但我是新的紅寶石軌道上,請不要考慮一些錯誤。 – 2011-12-14 17:20:32