diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-18 15:19:41 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-18 15:52:57 -0800 |
commit | 9e42f1b416771ba91455de711ae680b55640377e (patch) | |
tree | 55b6cdbca461738afbf194ee4d05cc3e4319b2d1 /activerecord/lib | |
parent | ba62a87b8b3ab2cffb6e8af6c110ec17b9c0bab2 (diff) | |
download | rails-9e42f1b416771ba91455de711ae680b55640377e.tar.gz rails-9e42f1b416771ba91455de711ae680b55640377e.tar.bz2 rails-9e42f1b416771ba91455de711ae680b55640377e.zip |
reduce method calls and loops when dealing with custom conditions
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index d89f87dbc7..74e957f828 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -219,10 +219,9 @@ module ActiveRecord associated_records(id_to_record_map.keys) { |some_ids| method = in_or_equal(some_ids) - conditions = right[reflection.foreign_key].send(*method) - conditions = custom_conditions.inject(conditions) do |ast, cond| - ast.and cond - end + conditions = right.create_and( + [right[reflection.foreign_key].send(*method)] + + custom_conditions) relation = associated_records_proxy.where(conditions) klass.connection.select_all(relation.arel.to_sql, 'SQL', relation.bind_values) |