Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update increment! documentation [ci skip] #25427

Merged
merged 1 commit into from
Jan 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions activerecord/lib/active_record/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,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_was(attribute.to_s) || 0)
Expand All @@ -348,10 +348,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
Original file line number Diff line number Diff line change
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