I have the following models:
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
I can get infosets fine via Product.infoset or Productset.infoset
But how do I get a Product or Productset via Infoset?
infoset.product just returns the infoset.
@infoset.infosetablewill return either a Product or a Productset, as appropriate.