has_and_belongs_to_many :favorite_media_files, :class =>
"MediaFile"
has_many :media_files
On May 4, 11:13 am, sbeam <szb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
> our app is a situation where users can upload files and also mark files
> uploaded by other users as their favorites. So for the favorites we are
> using a simple many-to-many with a tie table.
>
> So in attempting that it looks like
>
> class User < ActiveRecord::Base
>   has_and_belongs_to_many :media_file
>   has_many :media_file
> end
>
> class MediaFile < ActiveRecord::Base
>   has_and_belongs_to_many :user
>   belongs_to :user
> end
>
> but that won''t work because obv. if you call
>
> current_user.media_file.find(:all)
>
> there is no way to specify which association you are looking for. Or is
> there?
>
> if not what would be the most Rails-ish way of setting this up?
>
> thanks
> Sam
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---