diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-05-11 13:45:57 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-05-11 13:50:09 +0100 |
commit | 1f675ea8c731328aa4ba14187ba529f0b53fbf0d (patch) | |
tree | 22a947763a21f8ded900622f7c97e787125a03ea | |
parent | 446b0ffe1c804f4925867d785b9709d21105c707 (diff) | |
download | rails-1f675ea8c731328aa4ba14187ba529f0b53fbf0d.tar.gz rails-1f675ea8c731328aa4ba14187ba529f0b53fbf0d.tar.bz2 rails-1f675ea8c731328aa4ba14187ba529f0b53fbf0d.zip |
Succint save definition
-rw-r--r-- | activerecord/lib/active_record/validations.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 58391168a9..7a6fef0b7b 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -37,8 +37,7 @@ module ActiveRecord # The validation process on save can be skipped by passing false. The regular Base#save method is # replaced with this when the validations module is mixed in, which it is by default. def save(options={}) - return super if perform_validations(options) - false + perform_validations(options) ? super : false end def save_without_validation! @@ -48,8 +47,7 @@ module ActiveRecord # Attempts to save the record just like Base#save but will raise a RecordInvalid exception instead of returning false # if the record is not valid. def save!(options={}) - return super if perform_validations(options) - raise RecordInvalid.new(self) + perform_validations(options) ? super : raise(RecordInvalid.new(self)) end # Runs all the specified validations and returns true if no errors were added otherwise false. |