1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #25427 from eugeneius/update_increment_documentation

Update increment! documentation [ci skip]
This commit is contained in:
Kasper Timm Hansen 2017-01-08 20:56:38 +01:00 committed by GitHub
commit 7f19f30819
2 changed files with 8 additions and 10 deletions

View file

@ -338,10 +338,10 @@ module ActiveRecord
self self
end end
# Wrapper around #increment that saves the record. This method differs from # Wrapper around #increment that writes the update to the database.
# its non-bang version in that it passes through the attribute setter. # Only +attribute+ is updated; the record itself is not saved.
# Saving is not subjected to validation checks. Returns +true+ if the # This means that any other modified attributes will still be dirty.
# record could be saved. # Validations and callbacks are skipped. Returns +self+.
def increment!(attribute, by = 1) def increment!(attribute, by = 1)
increment(attribute, by) increment(attribute, by)
change = public_send(attribute) - (attribute_in_database(attribute.to_s) || 0) change = public_send(attribute) - (attribute_in_database(attribute.to_s) || 0)
@ -357,10 +357,10 @@ module ActiveRecord
increment(attribute, -by) increment(attribute, -by)
end end
# Wrapper around #decrement that saves the record. This method differs from # Wrapper around #decrement that writes the update to the database.
# its non-bang version in the sense that it passes through the attribute setter. # Only +attribute+ is updated; the record itself is not saved.
# Saving is not subjected to validation checks. Returns +true+ if the # This means that any other modified attributes will still be dirty.
# record could be saved. # Validations and callbacks are skipped. Returns +self+.
def decrement!(attribute, by = 1) def decrement!(attribute, by = 1)
increment!(attribute, -by) increment!(attribute, -by)
end end

View file

@ -202,11 +202,9 @@ The following methods trigger callbacks:
* `create` * `create`
* `create!` * `create!`
* `decrement!`
* `destroy` * `destroy`
* `destroy!` * `destroy!`
* `destroy_all` * `destroy_all`
* `increment!`
* `save` * `save`
* `save!` * `save!`
* `save(validate: false)` * `save(validate: false)`