From 176883a906e49a52fbfe9990bf18c16b3170161d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 24 May 2011 11:22:11 -0700 Subject: rescue record invalid exceptions and return false from the save method. fixes #796 --- activerecord/lib/active_record/persistence.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index b9041f44d8..e84a479a13 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -33,7 +33,11 @@ module ActiveRecord # +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. -- cgit v1.2.3