1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactor Relation#update a bit to avoid an extra Enumerator instance

This commit is contained in:
Carlos Antonio da Silva 2012-06-18 21:30:05 -03:00
parent b5fc47caf9
commit 32c65d8da3

View file

@ -300,7 +300,7 @@ module ActiveRecord
# Person.update(people.keys, people.values)
def update(id, attributes)
if id.is_a?(Array)
id.each.with_index.map {|one_id, idx| update(one_id, attributes[idx])}
id.map.with_index { |one_id, idx| update(one_id, attributes[idx]) }
else
object = find(id)
object.update_attributes(attributes)