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' –