Properly handle scoping with has_many :through. Fixes #14537.
Merge branch 'master' of https://github.com/habermann24/rails