When you compare the tags for the article on these pages:
http://blog.hasmanythrough.com/tags/tests to
http://blog.hasmanythrough.com/2007/5/2/getting-arbitrary-with-
assert_difference
you see that the tag “edge” is missing on the first of these pages.
Like probably every other Rails blog Mephisto does a variation of this:
def article
has_many :tags, :through => :taggings
end
For a usual list of articles tagged “foobar” Mephisto tries to: find
all articles that are tagged ‘foobar’ and eagerly preload all tags
for each article. But what it acutally does is: find all articles
that are tagged ‘foobar’ and eagerly preload the tag ‘foobar’.
Mephisto does this by something like this:
find(:all, :include => :tags, :conditions => [‘tags.name IN (?)’,
tag_names])
Is this ActiveRecord behaviour considered correct?
I.e. should this test pass or fail? Parked at Loopia
(Mephisto assumes it passes.)
If it is considered the right behaviour, is there any reasonable way
to get around this and perform the required query (“find all articles
that are tagged ‘foobar’ and eagerly preload all tags for each
article”) without constructing monstrous JOINs by hand? (e.g. see
Parked at Loopia)
Thanks!
–
sven fuchs fon: +49 (58 45) 98 89 58
artweb design fax: +49 (58 45) 98 89 57
breite straße 65 www: http://www.artweb-design.de
de-29468 bergen mail: [email protected]