Trying to do a select field for an admin interface.
What I have is not a traditional many-to-many relationship, but I imagine the principles are the same. I have an "Event" model and an "EventRelation" model...every Event can have many sub-events, and one primary event...so EventRelation has primary_event_id and sub_event_id fields.
How would I make a select field that would allow me to specify a primary_event for any given Event?
The relevant model code:
class Event 'primary_event_id', :class_name=>'EventRelation' has_one :primary_event_relation, :foreign_key=>'sub_event_id', :class_name=>'EventRelation' has_one :primary_event, :through=>:primary_event_relation, :foreign_key=>"primary_event_id" has_many :sub_events, :through=>:sub_event_relations, :foreign_key=>"sub_event_id" end class EventRelation 'Event', :foreign_key=>"primary_event_id" belongs_to :sub_event, :class_name=>'Event', :foreign_key=>"sub_event_id" end