On Thu, Jul 16, 2009 at 3:57 PM, The Barge <[email protected]
> wrote:

>
> Hrm - maybe I should just quote my actual code rather than the example.
> Actually, technically, no - the "hobbies" are NOT shared between people.
> So two people can't share the same hobby.
>
> Each Person has their own list of hobbies, and one of those is their
> "favorite" and I dont want to have some "favorite" boolean.  My actual
> code has nothing to do with people and hobbies, this was just a (poor)
> example.
>


I'm new so I don't have the full answer, but without the favorite boolean,
behind the scenes I think a table of  "HobbyFavorite" would be needed that
has person_id and hobby_id, unless I'm missing something.

So  it sounds like you need two "has_one" relationships defined?

both Person and Hobby would have:
has_one: favorite_hobby

You then could have a FavoriteHobby model object with
belongs_to: person
belongs_to: hobby

I'm not 100% this would work or is a good idea, but nobody else has
suggested anything yet, so I'm trying to learn in the process. Take any of
the above with a HUGE chunk of salt:)

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to