Skip to content

Commit

Permalink
- Updated persistence documentation to make it clear that save and sa…
Browse files Browse the repository at this point in the history
…ve! won't update a record if validation fails.

- Also fixed `update` method's documention to be uniform about this statement.
Fixes #20821

[ci skip]

[Vipul A M & pseidemann ]
  • Loading branch information
vipulnsward committed Jan 30, 2016
1 parent 2226140 commit 6c54f6c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions activerecord/lib/active_record/persistence.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def persisted?
# the existing record gets updated. # the existing record gets updated.
# #
# By default, save always runs validations. If any of them fail the action # By default, save always runs validations. If any of them fail the action
# is cancelled and #save returns +false+. However, if you supply # is cancelled and #save returns +false+, and the record won't be saved. However, if you supply
# validate: false, validations are bypassed altogether. See # validate: false, validations are bypassed altogether. See
# ActiveRecord::Validations for more information. # ActiveRecord::Validations for more information.
# #
Expand All @@ -133,7 +133,7 @@ def save(*args)
# the existing record gets updated. # the existing record gets updated.
# #
# By default, #save! always runs validations. If any of them fail # By default, #save! always runs validations. If any of them fail
# ActiveRecord::RecordInvalid gets raised. However, if you supply # ActiveRecord::RecordInvalid gets raised, and the record won't be saved. However, if you supply
# validate: false, validations are bypassed altogether. See # validate: false, validations are bypassed altogether. See
# ActiveRecord::Validations for more information. # ActiveRecord::Validations for more information.
# #
Expand Down Expand Up @@ -270,7 +270,7 @@ def update(attributes)
alias update_attributes update alias update_attributes update


# Updates its receiver just like #update but calls #save! instead # Updates its receiver just like #update but calls #save! instead
# of +save+, so an exception is raised if the record is invalid. # of +save+, so an exception is raised if the record is invalid and saving will fail.
def update!(attributes) def update!(attributes)
# The following transaction covers any possible database side-effects of the # The following transaction covers any possible database side-effects of the
# attributes assignment. For example, setting the IDs of a child collection. # attributes assignment. For example, setting the IDs of a child collection.
Expand Down

0 comments on commit 6c54f6c

Please sign in to comment.