keckbug-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-11 23:46 UTC
ActiveRecord naming help
Rails noob needing a direction to turn... I have a table of Pilots, and a table of Incidents, each incident has two Pilots associated, one is a victim and one is the attacker. I''d like to have my Incidents table have a "victim_id" and an "attacker_id" and map both of those to the Pilot''s table, but I''m not quite sure where to look in the doc''s for more info. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
class Incident < ActiveRecord::Base belongs_to :victim, :class_name => "Pilot", :foreign_key=>"victim_id" belongs_to :attacker, :class_name => "Pilot", :foreign_key=>"attacker_id" end On May 11, 7:46 pm, "keck...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <keck...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Rails noob needing a direction to turn... I have a table of Pilots, > and a table of Incidents, each incident has two Pilots associated, one > is a victim and one is the attacker. I''d like to have my Incidents > table have a "victim_id" and an "attacker_id" and map both of those to > the Pilot''s table, but I''m not quite sure where to look in the doc''s > for more info.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---