UPDATED/EDITED to clarify:
I have the following defined in my Blog AR object
scope :with_tag_tokens, lambda {|name_tokens|
joins(:tags).where(:tags => {:name_token => name_tokens}) unless name_tokens.empty?
}
Whereas the following query would return all Blogs with Tags that have a “name_token” attribute equal to 1 OR 3 OR 5 (If I passed in [1,3,5] of course) … I want to know if there is a way to construct a similar query that would only return Blogs that are only associated to Tags with the “name_tokens” of 1 AND 3 AND 5.
In other words … I only want to return Blog A if it is associated to Tag 1 and Tag 3 and Tag 4.
Thanks -wg
Whether or not this is an efficient way of handling this … it works
What do ya’ll think? Is there a better way? Perhaps going straight-up sql is the proper approach here … if so, I’m definitely interested in hearing back from others good or bad.
* UPDATE *
Here is what the sql looks like in case folks are interested:
Thanks