mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Rewrite ActiveRecord::Base#delete docs to remove false information about callbacks, mention return value, and improve clarity
This commit is contained in:
@@ -2502,14 +2502,16 @@ module ActiveRecord #:nodoc:
|
||||
create_or_update || raise(RecordNotSaved)
|
||||
end
|
||||
|
||||
# Deletes the record in the database and freezes this instance to reflect that no changes should
|
||||
# be made (since they can't be persisted).
|
||||
# Deletes the record in the database and freezes this instance to
|
||||
# reflect that no changes should be made (since they can't be
|
||||
# persisted). Returns the frozen instance.
|
||||
#
|
||||
# Unlike #destroy, this method doesn't run any +before_delete+ and +after_delete+
|
||||
# callbacks, nor will it enforce any association +:dependent+ rules.
|
||||
#
|
||||
# In addition to deleting this record, any defined +before_delete+ and +after_delete+
|
||||
# callbacks are run, and +:dependent+ rules defined on associations are run.
|
||||
# The row is simply removed with a SQL +DELETE+ statement on the
|
||||
# record's primary key, and no callbacks are executed.
|
||||
#
|
||||
# To enforce the object's +before_destroy+ and +after_destroy+
|
||||
# callbacks, Observer methods, or any <tt>:dependent</tt> association
|
||||
# options, use <tt>#destroy</tt>.
|
||||
def delete
|
||||
self.class.delete(id) unless new_record?
|
||||
freeze
|
||||
|
||||
Reference in New Issue
Block a user