aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorEloy Duran <eloy.de.enige@gmail.com>2009-03-12 16:37:50 +0100
committerEloy Duran <eloy.de.enige@gmail.com>2009-03-12 16:42:41 +0100
commitb304b0be013a05b19708659a350b89fc071e9a7d (patch)
treeda753cd5e6101631113257debfd0d21e80d1f801 /activerecord
parent53744c543880999a7ad3f1e026875df3283978f1 (diff)
downloadrails-b304b0be013a05b19708659a350b89fc071e9a7d.tar.gz
rails-b304b0be013a05b19708659a350b89fc071e9a7d.tar.bz2
rails-b304b0be013a05b19708659a350b89fc071e9a7d.zip
Fixed some spelling errors in documentation about AssociationCollection::destroy and AssociationCollection::destroy_all.
Also fixed some whitespace.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb48
1 files changed, 26 insertions, 22 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index ad375be184..bcf4a91f0b 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -20,7 +20,7 @@ module ActiveRecord
super
construct_sql
end
-
+
def find(*args)
options = args.extract_options!
@@ -41,7 +41,7 @@ module ActiveRecord
if sanitized_conditions = sanitize_sql(options[:conditions])
conditions << " AND (#{sanitized_conditions})"
end
-
+
options[:conditions] = conditions
if options[:order] && @reflection.options[:order]
@@ -49,12 +49,12 @@ module ActiveRecord
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,13 +142,6 @@ module ActiveRecord
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?
@@ -200,11 +193,11 @@ module ActiveRecord
end
end
- # Destroy +records+ and remove from this association calling +before_remove+
- # and +after_remove+ callbacks.
+ # Destroy +records+ and remove them from this association calling
+ # +before_remove+ and +after_remove+ callbacks.
#
- # Note this method will always remove records from database ignoring the
- # +:dependent+ option.
+ # Note that this method will _always_ remove records from the database
+ # ignoring the +:dependent+ option.
def destroy(*records)
remove_records(records) do |records, old_records|
old_records.each { |record| record.destroy }
@@ -219,14 +212,25 @@ module ActiveRecord
if @reflection.options[:dependent] && @reflection.options[:dependent] == :destroy
destroy_all
- else
+ else
delete_all
end
self
end
- # Destory all the records from this association
+ # 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.
def destroy_all
load_target
destroy(@target)
@@ -357,7 +361,7 @@ module ActiveRecord
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?
@@ -367,7 +371,7 @@ module ActiveRecord
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) }
@@ -453,8 +457,8 @@ module ActiveRecord
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"