0
I持って次のモデル:双方向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
微細なビアインフォセットを得ることができますしかし、どのように私はProduct
またはProductset
Infoset
を経由して入手できますか?
infoset.product
は、単に情報セットを返します。
私はそれを試みるときにちょうどmethod_missingを取得します。 –
待って...私は愚かな攻撃をしていると思う。もう一度試してみるとうまくいったようです。 –
私はコレクションのinfosetableを呼び出そうとしていました。 Derp。 'infoset = Infoset.where(:usp_sku => params [:usp_sku])infoset.infosetable' –