From 1f675ea8c731328aa4ba14187ba529f0b53fbf0d Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Tue, 11 May 2010 13:45:57 +0100 Subject: Succint save definition --- activerecord/lib/active_record/validations.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/validations.rb') 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. -- cgit v1.2.3