Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rescue record invalid exceptions and return false from the save metho…

…d. fixes #796
  • Loading branch information...
commit 79abb703e9c0d40e589e5d9014e3857a61c782d5 1 parent 1c079c5
@tenderlove tenderlove authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 activerecord/lib/active_record/persistence.rb
View
6 activerecord/lib/active_record/persistence.rb
@@ -36,7 +36,11 @@ def persisted?
# +save+ returns +false+. See ActiveRecord::Callbacks for further
# details.
def save(*)
- create_or_update
+ begin
+ create_or_update
+ rescue ActiveRecord::RecordInvalid
+ false
+ end
end
# Saves the model.
Please sign in to comment.
Something went wrong with that request. Please try again.