Hello,

I've a usually structure with Post has_many Tags through Taggings. All
works well and clean. But I'm having problems with the next scope on
Post:

scope :tagged, lambda {|tag_id| joins(:taggings).where(:taggings =>
{:tag_id => tag_id}) }

All works fine for call of only one Tag like: Post.tagged("sport") .
The problem comes when you want to show the adverts that have any tag
OR other, like well: Post.tagged(%w{sport people}). Then, the INNER
JOIN do that I may get repeated results of Post. For example, if I may
have two Post with "sport" and "people" tag each one, with the
previous call, I would get 4 results.

Thanks for help.

-- 
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