Amjith
2007-Oct-19 17:01 UTC
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 amjithps-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Oct-19 17:19 UTC
Re: How can i create 2 foreign key in a table referring key from one table?
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>> Thanks > amjithps-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Amjith Ps
2008-Mar-31 06:24 UTC
Re: How can i create 2 foreign key in a table referring key
Frederick Cheung 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---