Florencio Cano wrote:> How I can have two references from one table to another table?
> I have a table invitations that have a user_id pointing to the person
> who invites and I want another user_id to point to the person invited.
> Should I forget the conventions in this case?
I would definitely forget the conventions and make the columns
something like invited_by_id and invited_id. Then in your model:
belongs_to :invited_by, :class_name => "User", :foreign_key =>
"invited_by_id"
belongs_to :invited, :class_name => "User", :foreign_key =>
"invited_id"
@invitation.invited.name was invited by @invitation.invited_by.name
Dan Manges
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---