ActiveRecords - two fks

Hi,

 I have two database tables
 Briefly:
   Projects
      -type
      -designer_id
      -check_designer_id
      - ...
   Designers
      -name
      -...

 I want to create two foreign keys in Projects table and both with
 the same Designer table.

 How should I deal with that problem, I want to use ActiveRecords.
 Is it possible?

Zirael wrote:

Hi,

 I have two database tables
 Briefly:
   Projects
      -type
      -designer_id
      -check_designer_id
      - ...
   Designers
      -name
      -...

 I want to create two foreign keys in Projects table and both with
 the same Designer table.

 How should I deal with that problem, I want to use ActiveRecords.
 Is it possible?

Yes, Serving from memory (at work taking a break), look at belongs_to
:foreign_key to specify alternate/extra foreign key relationships…

class Project < ActiveRecord::Base
belongs_to :designer, :foreign_key=>“designer_id”
belongs_to :designer, :foreign_key=>“some_other_foreign_key_id”
end

class Designer < ActiveRecordBase
has_many :projects, :foreign_key=>“designer_id”
has_many :projects, :foreign_key=>“some_other_foreign_key_id”
end

Designer.find(:first).some_other_foreign_keys.each { etc… }

hope this helps

ilan