Hi!
I have two classes, 'node' and 'way', linked by 'way_node'. It's a fairly straightforward relationship:
node: has_many :way_nodes has_many :ways, :through => :way_nodes
way: has_many :way_nodes, :foreign_key => 'id', :order => 'sequence_id' has_many :nodes, :through => :way_nodes, :order => 'sequence_id'
way_node: belongs_to :node belongs_to :way, :foreign_key => :id
This typically results in queries like: SELECT [blah] FROM nodes LEFT OUTER JOIN way_nodes ON (nodes.id = way_nodes.node_id) LEFT OUTER JOIN ways ON (ways.id = way_nodes.id)
However, for one single query in the app, I'd like to join via a different table. In other words: SELECT [blah] FROM nodes LEFT OUTER JOIN new_table ON (nodes.id = new_table.node_id) LEFT OUTER JOIN ways ON (ways.id = new_table.id)
Is there any way of doing this? I'd wondered about the :joins option in 'find', but it only adds additional joins, rather than replacing the existing ones.
Thanks for any help!
cheers Richard