You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the documentation for Rails 4.1.7 specifies that the method clear:
Removes every object from the collection. This destroys the associated objects if they are associated with dependent: :destroy
However, given that ActiveRecord::Associations::CollectionProxy#clear simply delegates to delete_all and with the change to the implementation of delete_all this is no longer tru:
Removes all records from the association without calling callbacks on the associated records. It honors the :dependent option. However if the :dependent value is :destroy then in that case the :delete_all deletion strategy for the association is applied.
This may be an error in the documentation that needs to be updated, or an undesired effect of the new implementation of delete_all. I personally think that clear should keep honoring the dependent :destroy flag, for backwards compatibility among other reasons.
The text was updated successfully, but these errors were encountered:
pcrwebdesign
changed the title
Wrong documentation of has_many clear
Wrong documentation (or implementation) of has_many clear
May 15, 2015
Improve the guide about `has_many` `collection.clear` to indicate
the behavior for each dependent strategy according to
`collection.delete_all`.
Based on rails#17179, I changed the `collection.delete` docs to also
clarify the default strategy for each `hm` and `hm:t` associations.
Fixesrails#20170.
Improve the guide about `has_many` `collection.clear` to indicate
the behavior for each dependent strategy according to
`collection.delete_all`.
Based on rails#17179, I changed the `collection.delete` docs to also
clarify the default strategy for each `hm` and `hm:t` associations.
Fixesrails#20170.
the documentation for Rails 4.1.7 specifies that the method clear:
However, given that ActiveRecord::Associations::CollectionProxy#clear simply delegates to delete_all and with the change to the implementation of delete_all this is no longer tru:
This may be an error in the documentation that needs to be updated, or an undesired effect of the new implementation of delete_all. I personally think that clear should keep honoring the dependent :destroy flag, for backwards compatibility among other reasons.
The text was updated successfully, but these errors were encountered: