class Property < ActiveRecord::Base
has_many :property_agents
has_many :agents, :through => :property_agents
end
class Agent < ActiveRecord::Base
has_many :property_agents
has_many :properties, :through => :property_agents
end
class PropertyAgent < ActiveRecord::Base
belongs_to :agent
belongs_to :property
end
property_agents table
:agent_id
:property_id
:property_key # the id of the property on the agent's system
Of all the agents Property belongs to, *one* is the 'foo' agent
and one is the 'bar' agent.
These agents fulfill a slightly different role than the others. They
need to be referenced via the property_agents model as I need the
associated property_key.
so has_one foo_agent, class_name => agents
wouldn't work well, as it forgoes the join.