2015-09-06 109 views
0

我試圖去做通過路口表的查詢,但Rails的是給我下面的錯誤無法找到軌關聯模型

enter image description here

場館模型

class Venue < ActiveRecord::Base 


attr_accessible :address, :latitude, :longitude, :name, :phone, :suburb, :state, :country 
    after_validation :geocode 

    has_many :orders, through: :venues_orders 

    geocoded_by :full_address 


    def full_address 
    [address, suburb, state, country].compact.join(', ') 
    end 

end 

訂貨型號

class Order < ActiveRecord::Base 
    attr_accessible :fulfilled, :item, :placed, :person_id, :special_instructions, :priority, :flag, :milk 

    belongs_to :person 
    belongs_to :venue 

場地指令模型

class VenuesOrders < ActiveRecord::Base 
    attr_accessible :order_id, :venue_id 
end 
+0

你是不正確 – Emu

回答

2
class Venue < ActiveRecord::Base 

    has_many :orders, through: :venues_orders 
    has_many :venues_orders 

end 

class Order < ActiveRecord::Base 

    has_many :venues, through: :venues_orders 
    has_many :venues_orders 

end 

class VenuesOrders < ActiveRecord::Base 
    belongs_to :venue 
    belongs_to :order 
end 

有關詳細信息閱讀:RailsGuides

另一個建議:該公約創建join table是詞彙順序。像,OrdersVenues不是VenuesOrders

+0

謝謝,我回滾了模型,並重新創建使用詞法順序 –

+0

仍然收到相同的警告消息 –