Join conditions removed on habtm and has many through with conditions or STI

I just generated a ticket that I would appreciate some eyes on. https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3979-patch-join-conditions-removed-on-habtm-and-has-many-through-with-conditions-or-sti

Thanks, David Genord II