rails/rails — pull request #9859 by DanOlson (2013-03-21 20:25:05+00:00)
Title: Allow nested conditions passed to .where to build arel tables in some cases

When passing a hash of conditions to .where, instantiate an arel table
if the keys represent a table associated to engine's table. Maintain
existing behavior if the keys are attributes of engine's table.
This allows queries like these:

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

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