Nesting conditions in ActiveRecord
Rails 3.2.6 has caused some folks to experience regressions in their apps. It's usually because they were misusing nested conditions, before. It's true that joins/includes understand nested hashes of association references, but in the where clause, stock ActiveRecord doesn't assign any special importance to that nesting, and in fact, as of 3.2.6, actively prevents it. You should rewrite:
Model.joins(:other_models => :still_other_models).where(
:other_models => {:still_other_models => {:attribute => 'value'}}
)
as:
Model.joins(:other_models => :still_other_models).where(
:still_other_models => {:attribute => 'value'}
)
Written by Ernie Miller
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#