Permalink
Browse files

Use Enumerable#with_index. We're on Ruby > 1.8.7

  • Loading branch information...
1 parent ad912c0 commit 49bf8597e674eafc2f180360e0c3c52f2b343a72 @amatsuda amatsuda committed Jul 8, 2011
Showing with 1 addition and 2 deletions.
  1. +1 −2 activerecord/lib/active_record/relation.rb
@@ -250,8 +250,7 @@ def update_all(updates, conditions = nil, options = {})
# Person.update(people.keys, people.values)
def update(id, attributes)
if id.is_a?(Array)
- idx = -1
- id.collect { |one_id| idx += 1; update(one_id, attributes[idx]) }
+ id.each.with_index.map {|one_id, idx| update(one_id, attributes[idx])}
else
object = find(id)
object.update_attributes(attributes)

0 comments on commit 49bf859

Please sign in to comment.