0
我有以下型号:双向polymophic关系
class Infoset < ActiveRecord::Base
belongs_to :infosetable, :polymorphic => true
end
class Product < ActiveRecord::Base
belongs_to :productset
has_one :infoset, :as => :infosetable, :dependent => :destroy
end
class Productset < ActiveRecord::Base
has_one :infoset, :as => :infosetable, :dependent => :destroy
has_many :products
end
我可以通过Product.infoset
或Productset.infoset
信息集细,但我怎么得到通过Infoset
Product
或Productset
?
infoset.product
只是返回信息。
我刚刚得到method_missing,当我尝试。 –
等等...我想我有一个愚蠢的攻击。试了一遍,它似乎工作.. –
我试图打电话infosetable集合。 DERP。 'infoset = Infoset.where(:usp_sku => params [:usp_sku])infoset.infosetable' –