> The second question (perhaps a datamapper question) arises in the same
> context...
>
> The Registration model belongs to both the first_person and the
> second_person, and both are instances of the User class. So in my
> Registration class I tried something like -
>
> class Registration
>  belongs_to :first_person, :class_name => User
>  belongs_to :second_person, :class_name => User
> end
>
> The problem of course is that I end up with two foreign keys with the
> identical name: 'user_id'. What's the right way to deal with this kind
> of situation? I tried a ':foreign_key' option, which apparently works
> in Rails, but that doesn't seem to help here.

U can do the following:

class Registration
  belongs_to :first_person, :class_name => User, :child_key =>
[:first_person_id]
  belongs_to :second_person, :class_name => User, :child_key =>
[:second_person_id]
end

See http://datamapper.org/doku.php?id=docs:associations

Cheers

-- 
http://ngty77.blogspot.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to