you need 2 foriegn keys. Then add the :foriegn_key => :user2_id to
has_many and belongs_to
On Aug 8, 1:05 pm, coelho coelho
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hello,
>
> I have a model that contains two fields associated with the same table,
> I hooked one up using the standard has_many association but I have no
> clue on how to do the second one.
> here are my models
>
> class Task < ActiveRecord::Base
> belongs_to :user #works fine associating through the user_id field in
> the table
>
> # belongs_to :user2
> #I don''t know what to place here, but I need to associate field
> resquester_id to #the users tables too
>
> end
>
> class User < ActiveRecord::Base
> has_many :tasks
> end
>
> appreciate any help
> Coelho
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---