Permalink
Browse files

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

  • Loading branch information...
1 parent b5fc47c commit 32c65d8da3fd28f8577bc23695846d47cdaac6fb @carlosantoniodasilva carlosantoniodasilva committed Jun 19, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/relation.rb
@@ -300,7 +300,7 @@ def update_all(updates)
# 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)

0 comments on commit 32c65d8

Please sign in to comment.