所以我有這些關係:我如何得到這個:通過?
位置:
has_many :services
has_many :products, :through => :services
產品:
has_many :services
has_many :locations, :through => :services
has_many :add_ons
和服務:
belongs_to :product
belongs_to :location
has_many :service_add_ons
has_many :add_ons, :through => :service_add_ons
一個service_add_on:
belongs_to :service
belongs_to :add_on
我該怎麼寫:通過它將返回一個位置,它的產品和每個產品的add_ons? 迄今爲止我有:
wants.json { render :json => @location.to_json(:include => {:products => {:add_ons}}) }
這顯然不工作。我能做些什麼來改變這一點,並使其工作?
你的產品模型是怎麼樣的? – 2010-08-31 17:20:59
has_many:services has_many:locations,:through =>:services has_many:add_ons ...我將它添加到 – thatmiddleway 2010-08-31 17:45:42