I have a legacy database that I'm working on getting ActiveRecord to work with. I've run into a problem with join tables. I have the following:
class TvShow < ActiveRecord::Base
set_table_name "tvshow"
set_primary_key "idShow"
end
class Episode < ActiveRecord::Base
set_table_name "episode"
set_primary_key "idEpisode"
end
And then I have a table called tvshowlinkepisode that has 2 fields: idShow, idEpisode So I have 2 tables and a join between them (so a many to many relationship), however the join uses non-standard foreign keys. My first thought was to create a model called TvShowEpisodeLink but there isn't a primary key. The idea was that since the foreign keys are non-standard I could use the set_foreign_key and have some control. Ultimately I want to say something like TvShow.find(:last).episodes or Episode.find(:last).tv_show. How do I get there?