Hello! I''ve got a service ticket model that originates from one user but can be assigned to another. I''ve got two columns in my table, user_id (for the orginator) and assigned_id (for the person assigned). Both ids are from my users table. How do I tell my ticket model that assigned_id is another instance of User? I tried belongs_to :user belongs_to :assigned, :class_name => "User", :foreign_key => "user_id" But it seems to link the two -- when I changed assignment, the original user also changes. Thanks, Eric Wagoner
Hi ! 2005/10/13, Eric Wagoner <ewagoner@gmail.com>:> I've got a service ticket model that originates from one user but can > be assigned to another. I've got two columns in my table, user_id (for > the orginator) and assigned_id (for the person assigned). Both ids are > from my users table.class ServiceTicket belongs_to :originator, :class_name => 'User', :foreign_key => 'user_id' belongs_to :assignee, :class_name => 'User', :foreign_key => 'assigned_id' end That should do the trick ! François _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Eric Wagoner wrote:> Hello! > > I''ve got a service ticket model that originates from one user but can > be assigned to another. I''ve got two columns in my table, user_id (for > the orginator) and assigned_id (for the person assigned). Both ids are > from my users table. > > How do I tell my ticket model that assigned_id is another instance of User? > > I tried > > belongs_to :user > belongs_to :assigned, > :class_name => "User", > :foreign_key => "user_id"^^^^^^^^^ Shouldn''t that be "assigned_id"? regards Justin> > But it seems to link the two -- when I changed assignment, the > original user also changes. > > Thanks, > Eric Wagoner