How can i create 2 foreign key in a table referring key from one table?

hi Friends,
i have a accounts table and a transaction table see the schema below

  1.   acc_master
    

    acc_id int(11) – primary key
    acc_name
    cur_balance
    regist_date
    update_date

  2.  acc_trans
    

trans_id – primary key
trans_from – foreign key reference to acc_id (acc_master)
trans_to — foreign key reference to acc_id (acc_master)
trans_date
trans_amount
trans_narration

How can i create a migration file for the 2nd table … how will i
represent 2 foreign key from same table in Rails?
Can any one help for this question please?

Thanks
[email protected]

On 19 Oct 2007, at 18:01, Amjith wrote:

How can i create a migration file for the 2nd table … how will i
represent 2 foreign key from same table in Rails?
Can any one help for this question please?

belongs_to :foo_1, :class_name => ‘Foo’, :foreign_key => ‘foo_1_id’
belongs_to :foo_2, :class_name => ‘Foo’, :foreign_key => ‘foo_2_id’

Fred

Frederick C. wrote:

On 19 Oct 2007, at 18:01, Amjith wrote:

How can i create a migration file for the 2nd table … how will i
represent 2 foreign key from same table in Rails?
Can any one help for this question please?

belongs_to :foo_1, :class_name => ‘Foo’, :foreign_key => ‘foo_1_id’
belongs_to :foo_2, :class_name => ‘Foo’, :foreign_key => ‘foo_2_id’

Fred

Thankyou verymuch Fred

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