In my application, Users can start and participate in Discussions. They can also Tag Discussions; when they do so, a Tag is created containing the name of the tag (if it didn't already exist), and a Tagging, which remembers which User tagged which Discussion with what Tag, is created too.
So inside the Discussion model we have this:
has_many :taggings
has_many :tags, :through => :taggings
I'm trying to create an easy way to retrieve all the Tags on a Discussion from one User. Ideally, named_scopes would be used judiciously to keep things nice and clean. I think it should look something like this:
tags = @discussion.tags.from_user(@user)
Writing this named_scope inside the Tag class is turning out to be very difficult. What should it look like? Do I need to join it with the Taggings table somehow?