提交 49bf8597 编写于 作者: A Akira Matsuda

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

上级 ad912c08
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册