Thomas
2007-Sep-09 00:56 UTC
joining tables where foreign key is not the [singular_of_other_table]_id
I am rather new to RoR and am having the following issue. I have read some conflicting posts so I wanted to see what people have to say for my particular example. Here is what I have. class Expense < ActiveRecord::Base class Person < ActiveRecord::Base A person has the following fields (in the people table). :fname, :string :lname, :string :email, :string An expense has the following fields (in the expenses table). :purchaser_id, :integer :amount, :decimal :description, :string :event_id, :integer A person is the purchaser of an expense, but I don''t want to use person_id as the field name in the expense model. How do I create a has_many and belongs_to relationship. Clearly, a person will have many expenses (as a purchaser) and an expense will belong to a purchaser (or person). Any help would be greatly appreciated. Thanks, Thomas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---