rails/rails — pull request #9906 by DanOlson (2013-03-24 19:11:15+00:00)
Title: Fix bug with nested conditions passed to .where()

Recusion in PredicateBuilder.build_from_hash() so that passing a nested
hash of conditions to .where will build a valid SQL query.
This allows queries like these:

Post.joins(author: :organization).
where(authors: { organizations: { name: 'Acme' } } )

This would fix issue #9511
https://github.com/rails/rails/issues/9511

Previously, that same query's WHERE clause would read:

"... WHERE "authors"."organizations" ...

which would break because the 'authors' table doesn't have an 'organizations' column. This change will instantiate an Arel::Table for 'organizations', and the query will be built correctly.