2
我正在嘗試查找適用於聯繫人的所有術語和課程。活動記錄加入3個表格
這裏是我的模型
class Register < ActiveRecord::Base
belongs_to :session
belongs_to :contact
end
class Session < ActiveRecord::Base
belongs_to :term
belongs_to :course
has_many :registers
has_many :contacts, :through => :registers
end
這裏是找到一個寫
@data = Register.all :joins => {:session =>[:term, :course]} , :conditions => ["contact_id = ?", params[:id]]
當我運行查詢我得到的是會議記錄沒有條款或課程
謝謝
Alex
Thanks !, that worked – Alex 2010-06-20 12:15:30
請標記爲已回答。 – thomasfedb 2010-06-20 13:11:35