Permalink
Browse files

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

fixes #796
  • Loading branch information...
1 parent 559d809 commit 176883a906e49a52fbfe9990bf18c16b3170161d @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 176883a

Please sign in to comment.