diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-24 11:22:11 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-24 11:22:11 -0700 |
commit | 176883a906e49a52fbfe9990bf18c16b3170161d (patch) | |
tree | 00e0431398d656742280bb2c4f858398c32762f6 | |
parent | 559d809609570466ea1f86b0255e0269b43a2a3b (diff) | |
download | rails-176883a906e49a52fbfe9990bf18c16b3170161d.tar.gz rails-176883a906e49a52fbfe9990bf18c16b3170161d.tar.bz2 rails-176883a906e49a52fbfe9990bf18c16b3170161d.zip |
rescue record invalid exceptions and return false from the save method. fixes #796
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 6 |
1 files changed, 5 insertions, 1 deletions
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. |