Permalink
Browse files

rescue record invalid exceptions and return false from the save method.

fixes #796
  • Loading branch information...
1 parent 1d864e8 commit 656e7b08073fa4e620a6d9ce0de554f8f5be96bb @tenderlove tenderlove committed May 24, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 activerecord/lib/active_record/persistence.rb
@@ -33,7 +33,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.

0 comments on commit 656e7b0

Please sign in to comment.