While attempting to work around #8838, I found out that specifying :joins on a find scoped by a HABTM association is not allowed, because the finder uses an INNER JOIN to fetch the records. e.g.
# Fails due to duplicate table names
Tag.find(8).posts.find(:all, :include => :tags)
# Fails as :joins option is not included in the generated SQL
Tag.find(8).posts.find(:all, :joins => sql_to_manually_eager_load)
This patch lets you use :joins successfully in such situations. I'm not sure how to go about testing it, and for some reason opening base_test.rb is crashing my text editor (Notepad++). It's a one-liner and doesn't break any existing tests, though.