aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 4a5ccdc597..d1cb3783e7 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -99,7 +99,7 @@ module ActiveRecord
# for updating all records in a single query.
def update(id = :all, attributes)
if id.is_a?(Array)
- id.map.with_index { |one_id, idx| update(one_id, attributes[idx]) }
+ id.map.with_index { |one_id, idx| update(one_id, attributes[idx]) }.compact
elsif id == :all
all.each { |record| record.update(attributes) }
else
@@ -112,6 +112,7 @@ module ActiveRecord
object.update(attributes)
object
end
+ rescue RecordNotFound
end
# Destroy an object (or multiple objects) that has the given id. The object is instantiated first,
@@ -135,10 +136,11 @@ module ActiveRecord
# Todo.destroy(todos)
def destroy(id)
if id.is_a?(Array)
- id.map { |one_id| destroy(one_id) }
+ id.map { |one_id| destroy(one_id) }.compact
else
find(id).destroy
end
+ rescue RecordNotFound
end
# Deletes the row with a primary key matching the +id+ argument, using a