has_and_belongs_to_many :favourite_resources, :class_name =>
"Resource",
:join_table => "resources_users"
Try that out.
On Dec 18, 2007 12:33 AM, Stefano Bernardi
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
>
> Ok,
> i have a little question.
>
> I am developing an app and writing down the schema for my database i
> have this 2 entities (we call them like this in italian, don''t
know the
> right word in english, sorry).
>
> USER and RESOURCE
>
> An user can submit a resource. So that''s a one-to-many
relationship with
> a simple has_many :resources and belongs_to :user
>
> I then want users to have favourites Resources. So that''s a
many-to-many
> relationship but on the same entities as before!
>
> How should i handle that?
> Should i create a favourite table with user_id and resource_id and then
> write something like: has_many_and_belongs_to :user, throught
> :favourite?
> Should i use the join_table option?
> Should i change something on the user and resource tables?
>
> Feel free to give your suggestions! Thank you!
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--
Ryan Bigg
http://www.frozenplague.net
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---