Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #25427 from eugeneius/update_increment_documentation
Browse files Browse the repository at this point in the history
Update increment! documentation [ci skip]
  • Loading branch information
kaspth committed Jan 8, 2017
2 parents ee47aab + 115e314 commit 7f19f30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 8 additions & 8 deletions activerecord/lib/active_record/persistence.rb
Expand Up @@ -338,10 +338,10 @@ def increment(attribute, by = 1)
self
end

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

# Wrapper around #decrement that saves the record. This method differs from
# its non-bang version in the sense that it passes through the attribute setter.
# Saving is not subjected to validation checks. Returns +true+ if the
# record could be saved.
# Wrapper around #decrement that writes the update to the database.
# Only +attribute+ is updated; the record itself is not saved.
# This means that any other modified attributes will still be dirty.
# Validations and callbacks are skipped. Returns +self+.
def decrement!(attribute, by = 1)
increment!(attribute, -by)
end
Expand Down
2 changes: 0 additions & 2 deletions guides/source/active_record_callbacks.md
Expand Up @@ -202,11 +202,9 @@ The following methods trigger callbacks:

* `create`
* `create!`
* `decrement!`
* `destroy`
* `destroy!`
* `destroy_all`
* `increment!`
* `save`
* `save!`
* `save(validate: false)`
Expand Down

0 comments on commit 7f19f30

Please sign in to comment.