diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-25 14:34:13 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-25 14:34:13 -0700 |
commit | 3fe9951fcce97edbc7d1443f165a0b2cb82de1ef (patch) | |
tree | 82952b34d6922aeec0411139d32131df60dd840b /activerecord/lib/active_record | |
parent | f855090a78b99fc9e1414a1fab21473ef10bc00c (diff) | |
download | rails-3fe9951fcce97edbc7d1443f165a0b2cb82de1ef.tar.gz rails-3fe9951fcce97edbc7d1443f165a0b2cb82de1ef.tar.bz2 rails-3fe9951fcce97edbc7d1443f165a0b2cb82de1ef.zip |
refactoring AST building
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index 7dfb142bb8..9c79e6225a 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -217,13 +217,11 @@ module ActiveRecord associated_records_proxy.joins_values = [join] associated_records_proxy.select_values = select - method = ids.length > 1 ? 'in' : 'eq' - all_associated_records = associated_records(ids) do |some_ids| + method = some_ids.length == 1 ? ['eq', some_ids.first] : + ['in', some_ids] - conditions = right[reflection.primary_key_name].send( - method, some_ids.length == 1 ? some_ids.first : some_ids - ) + conditions = right[reflection.primary_key_name].send(*method) conditions = conditions.and(custom_conditions) unless custom_conditions.empty? associated_records_proxy.where(conditions).to_a |