From e9020a6ce63e7c3454cd8b14b1c9332c4c915a47 Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Fri, 5 Oct 2012 16:14:34 +0800 Subject: Add CollectionAssociation#destroy to ActiveRecord::Association::ClassMethods code docs --- activerecord/lib/active_record/associations.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 258d602afa..69b95f814c 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -190,10 +190,10 @@ module ActiveRecord # * Project#portfolio, Project#portfolio=(portfolio), Project#portfolio.nil? # * Project#project_manager, Project#project_manager=(project_manager), Project#project_manager.nil?, # * Project#milestones.empty?, Project#milestones.size, Project#milestones, Project#milestones<<(milestone), - # Project#milestones.delete(milestone), Project#milestones.find(milestone_id), Project#milestones.all(options), - # Project#milestones.build, Project#milestones.create + # Project#milestones.delete(milestone), Project#milestones.destroy(mileston), Project#milestones.find(milestone_id), + # Project#milestones.all(options), Project#milestones.build, Project#milestones.create # * Project#categories.empty?, Project#categories.size, Project#categories, Project#categories<<(category1), - # Project#categories.delete(category1) + # Project#categories.delete(category1), Project#categories.destroy(category1) # # === A word of warning # @@ -236,6 +236,7 @@ module ActiveRecord # others.clear | X | X | X # others.delete(other,other,...) | X | X | X # others.delete_all | X | X | X + # others.destroy(other,other,...) | X | X | X # others.destroy_all | X | X | X # others.find(*args) | X | X | X # others.exists? | X | X | X @@ -1031,6 +1032,12 @@ module ActiveRecord # If the :through option is used, then the join records are deleted (rather than # nullified) by default, but you can specify :dependent => :destroy or # :dependent => :nullify to override this. + # [collection.destroy(object, ...)] + # Removes one or more objects from the collection by running destroy on + # each record, regardless of any dependent option, ensuring callbacks are run. + # + # If the :through option is used, then the join records are destroyed + # instead, not the objects themselves. # [collection=objects] # Replaces the collections content by deleting and adding objects as appropriate. If the :through # option is true callbacks in the join models are triggered except destroy callbacks, since deletion is @@ -1074,6 +1081,7 @@ module ActiveRecord # * Firm#clients (similar to Clients.all :conditions => ["firm_id = ?", id]) # * Firm#clients<< # * Firm#clients.delete + # * Firm#clients.destroy # * Firm#clients= # * Firm#client_ids # * Firm#client_ids= @@ -1425,6 +1433,9 @@ module ActiveRecord # [collection.delete(object, ...)] # Removes one or more objects from the collection by removing their associations from the join table. # This does not destroy the objects. + # [collection.destroy(object, ...)] + # Removes one or more objects from the collection by running destroy on each association in the join table, overriding any dependent option. + # This does not destroy the objects. # [collection=objects] # Replaces the collection's content by deleting and adding objects as appropriate. # [collection_singular_ids] @@ -1461,6 +1472,7 @@ module ActiveRecord # * Developer#projects # * Developer#projects<< # * Developer#projects.delete + # * Developer#projects.destroy # * Developer#projects= # * Developer#project_ids # * Developer#project_ids= -- cgit v1.2.3