I want to do some seemingly simple associations:
class OrderWizard < ActiveRecord::Base
belongs_to :buyer_wizard, :class_name => MiniWizard.name
belongs_to :seller_wizard, :class_name => MiniWizard.name
end
class MiniWizard < ActiveRecord::Base
has_one :order_wizard, :foreign_key = '????' # Could be buyer_wizard_id or seller_wizard_id
def is_buyer_wizard?
??
end
def is_seller_wizard?
??
end
end
-
An associated MiniWizard needs to know who is connecting to it. Assuming has_many :through best way to go? If so, how would the models look?
-
A MiniWizard instance needs to know if it’s a buyer or seller. Stuck on how to do this.
You actually probably want two associations, for example, something like this might represent the relationships more accurately: