I have a kind of legacy db structure with rails. It has a structure like:
apples
id:
number:
oranges
apple_id: (links to apples.number)
pears
apple_id: (links to apples.id)
Models like:
Apple has_many :oranges, :foreign_key => ?, :primary_key => ?
has_many :pears
Orange belongs_to :apple, :foreign_key => ?, :primary_key => ?
Pears belongs_to :apple
I'm stuck with how to write the association. I'm having difficulty understanding the documentation on foreign keys and primary keys and which goes with has_many and belongs_to