Displaying 2 results from an estimated 2 matches for "opened_by".
2005 Dec 14
5
belongs_to and multiple foreign keys
Hi all,
I''m confused about how I''m supposed to specify a belongs_to relationship when
the table includes multiple columns that reference the same parent table.
In my case I have a "schedules" table with "opened_by" and "closed_by" columns,
that both reference the "users" table. In theory, they can be two different
user ids.
table schedules (
...
opened_by int,
closed_by int,
foreign key (closed_by) references users (id),
foreign key (opened_by) references user...
2006 Feb 14
6
Multiple associations to the same class
Hi,
I cannot seem to create associations like this:
class Project < ActiveRecord::Base
belongs_to :manager, :class_name => ''User'', :foreign_key => ''manager''
belongs_to :liaison, :class_name => ''User'', :foreign_key => ''liaison''
end
p = Project.new
p.manager
=> 1
trying to retrieve associated objects