diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-08 06:05:20 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-08 06:05:20 -0700 |
commit | 3a1ec9b544c6056fb69b831cd3ed551a656a9b61 (patch) | |
tree | 6666da385707de5ffa5abb1a4a35e739a6f9ba43 /activerecord/lib/active_record | |
parent | ad912c08a91b90f6a7b30ae75b4a3a5f6c513bd4 (diff) | |
parent | dab0de4a2058abe60c95ff7fdead43ad2b1f786e (diff) | |
download | rails-3a1ec9b544c6056fb69b831cd3ed551a656a9b61.tar.gz rails-3a1ec9b544c6056fb69b831cd3ed551a656a9b61.tar.bz2 rails-3a1ec9b544c6056fb69b831cd3ed551a656a9b61.zip |
Merge pull request #2011 from amatsuda/with_index
replaced some "i += 1" sort of codes with Enumerable#with_index
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index aa7f7d6cea..6258a16d0f 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -250,8 +250,7 @@ module ActiveRecord # 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) |