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