diff options
author | Xavier Noria <fxn@hashref.com> | 2008-08-26 03:26:54 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2008-08-26 03:26:54 +0200 |
commit | 5db2f199aba9aa8d00adefa8237922ad684aca03 (patch) | |
tree | 430aa4830af6abbc2c93d1dd7e151246dba808e8 /activerecord/lib/active_record | |
parent | eaa9c064390c7c303be6e6571a14d7dd611ed07b (diff) | |
download | rails-5db2f199aba9aa8d00adefa8237922ad684aca03.tar.gz rails-5db2f199aba9aa8d00adefa8237922ad684aca03.tar.bz2 rails-5db2f199aba9aa8d00adefa8237922ad684aca03.zip |
Reworded and corrected docs of AR#save and AR#save!
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 8e40b331d9..b282ea931e 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2237,22 +2237,40 @@ module ActiveRecord #:nodoc: defined?(@new_record) && @new_record end - # * No record exists: Creates a new record with values matching those of the object attributes. - # * A record does exist: Updates the record with values matching those of the object attributes. - # - # Note: If your model specifies any validations then the method declaration dynamically - # changes to: - # save(perform_validation=true) - # Calling save(false) saves the model without running validations. - # See ActiveRecord::Validations for more information. + # :call-seq: + # save(perform_validation = true) + # + # Saves the model. + # + # If the model is new a record gets created in the database, otherwise + # the existing record gets updated. + # + # If +perform_validation+ is true validations run. If any of them fail + # the action is cancelled and +save+ returns +false+. If the flag is + # false validations are bypassed altogether. See + # ActiveRecord::Validations for more information. + # + # There's a series of callbacks associated with +save+. If any of the + # <tt>before_*</tt> callbacks return +false+ the action is cancelled and + # +save+ returns +false+. See ActiveRecord::Callbacks for further + # details. def save create_or_update end - # Attempts to save the record, but instead of just returning false if it couldn't happen, it raises an - # ActiveRecord::RecordNotSaved exception. However, if the callback chain raises ActiveRecord::Rollback - # to rollback the transaction that wraps <tt>save!</tt> no exception is raised, <tt>save!</tt> just - # returns +nil+. See ActiveRecord::Callbacks for further details. + # Saves the model. + # + # If the model is new a record gets created in the database, otherwise + # the existing record gets updated. + # + # With <tt>save!</tt> validations always run. If any of them fail + # ActiveRecord::RecordInvalid gets raised. See ActiveRecord::Validations + # for more information. + # + # There's a series of callbacks associated with <tt>save!</tt>. If any of + # the <tt>before_*</tt> callbacks return +false+ the action is cancelled + # and <tt>save!</tt> raises ActiveRecord::RecordNotSaved. See + # ActiveRecord::Callbacks for further details. def save! create_or_update || raise(RecordNotSaved) end |