Multi-table join issue with Legacy tables

Hi there,

I have been banging my head against the wall and need to reach out and
ask for help.

I have three tables and thus three models, Cars, entity_map, and
wiki_edits.

Cars has a primary key named id
entity_map has two columns: ref_id and entity_id
wiki_edits has two columns: id (PK) and entity_id

to find a car's wiki_edits I would issue the following SQL fragment
join

from cars join entity_map on (cars.id = entity_map.ref_id) join
wiki_edits on (entity_map.entity_id = wiki_edits.entity_id)

The schema is set so I cannot change it. How would I use a combination
of has_many, belongs_to, and through attributes to define this
relationship inside the models? I have tried a bunch of different
approaches and have thus failed.

Any insight would be great.

Thanks in advance.
Nick Shanny