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.

class Incident < ActiveRecord::Base
belongs_to :victim, :class_name =>
“Pilot”, :foreign_key=>“victim_id”
belongs_to :attacker, :class_name =>
“Pilot”, :foreign_key=>“attacker_id”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs