Permalink
Browse files

Revert "Fixed some spelling errors in documentation about Association…

…Collection::destroy and AssociationCollection::destroy_all."

This reverts commit b304b0b.
  • Loading branch information...
1 parent b304b0b commit 8e277f89cdbf7266c700703e437525cc8ea35c1d @alloy alloy committed Mar 12, 2009
Showing with 22 additions and 26 deletions.
  1. +22 −26 activerecord/lib/active_record/associations/association_collection.rb
@@ -20,7 +20,7 @@ def initialize(owner, reflection)
super
construct_sql
end
-
+
def find(*args)
options = args.extract_options!
@@ -41,20 +41,20 @@ def find(*args)
if sanitized_conditions = sanitize_sql(options[:conditions])
conditions << " AND (#{sanitized_conditions})"
end
-
+
options[:conditions] = conditions
if options[:order] && @reflection.options[:order]
options[:order] = "#{options[:order]}, #{@reflection.options[:order]}"
elsif @reflection.options[:order]
options[:order] = @reflection.options[:order]
end
-
+
# Build options specific to association
construct_find_options!(options)
-
+
merge_options_from_reflection!(options)
-
+
# Pass through args exactly as we received them.
args << options
@reflection.klass.find(*args)
@@ -142,6 +142,13 @@ def transaction(*args)
end
end
+ # Remove all records from this association
+ def delete_all
+ load_target
+ delete(@target)
+ reset_target!
+ end
+
# Calculate sum using SQL, not Enumerable
def sum(*args)
if block_given?
@@ -193,11 +200,11 @@ def delete(*records)
end
end
- # Destroy +records+ and remove them from this association calling
- # +before_remove+ and +after_remove+ callbacks.
+ # Destroy +records+ and remove from this association calling +before_remove+
+ # and +after_remove+ callbacks.
#
- # Note that this method will _always_ remove records from the database
- # ignoring the +:dependent+ option.
+ # Note this method will always remove records from database ignoring the
+ # +:dependent+ option.
def destroy(*records)
remove_records(records) do |records, old_records|
old_records.each { |record| record.destroy }
@@ -212,25 +219,14 @@ def clear
if @reflection.options[:dependent] && @reflection.options[:dependent] == :destroy
destroy_all
- else
+ else
delete_all
end
self
end
- # Remove all records from this association.
- #
- # See delete for more info.
- def delete_all
- load_target
- delete(@target)
- reset_target!
- end
-
- # Destroy all the records from this association.
- #
- # See destroy for more info.
+ # Destory all the records from this association
def destroy_all
load_target
destroy(@target)
@@ -361,7 +357,7 @@ def load_target
loaded if target
target
end
-
+
def method_missing(method, *args)
if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))
if block_given?
@@ -371,7 +367,7 @@ def method_missing(method, *args)
end
elsif @reflection.klass.scopes.include?(method)
@reflection.klass.scopes[method].call(self, *args)
- else
+ else
with_scope(construct_scope) do
if block_given?
@reflection.klass.send(method, *args) { |*block_args| yield(*block_args) }
@@ -457,8 +453,8 @@ def callback(method, record)
def callbacks_for(callback_name)
full_callback_name = "#{callback_name}_for_#{@reflection.name}"
@owner.class.read_inheritable_attribute(full_callback_name.to_sym) || []
- end
-
+ end
+
def ensure_owner_is_not_new
if @owner.new_record?
raise ActiveRecord::RecordNotSaved, "You cannot call create unless the parent is saved"

0 comments on commit 8e277f8

Please sign in to comment.