aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-06-24 11:40:23 -0300
committerEmilio Tagua <miloops@gmail.com>2010-06-24 11:40:23 -0300
commitd9f199e1238a723432a2005c405fc5ae22dea24b (patch)
tree52dc249b4f747c6dd04ba2d9d0927adc3e9312bc
parentfdb7f84eb10c5e59490764a1a259aa00a1fcfe5f (diff)
downloadrails-d9f199e1238a723432a2005c405fc5ae22dea24b.tar.gz
rails-d9f199e1238a723432a2005c405fc5ae22dea24b.tar.bz2
rails-d9f199e1238a723432a2005c405fc5ae22dea24b.zip
Don't define block, just yield if block is given.
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index f8d46bcb48..186b531ffb 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -26,10 +26,10 @@ module ActiveRecord
delegate :group, :order, :limit, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :to => :scoped
- def select(select = nil, &block)
+ def select(select = nil)
if block_given?
load_target
- @target.select(&block)
+ @target.select.each { |e| yield e }
else
scoped.select(select)
end
@@ -123,7 +123,7 @@ module ActiveRecord
end
end
- # Add +records+ to this association. Returns +self+ so method calls may be chained.
+ # Add +records+ to this association. Returns +self+ so method calls may be chained.
# Since << flattens its argument list and inserts each record, +push+ and +concat+ behave identically.
def <<(*records)
result = true
@@ -168,7 +168,7 @@ module ActiveRecord
reset_target!
reset_named_scopes_cache!
end
-
+
# Calculate sum using SQL, not Enumerable
def sum(*args)
if block_given?
@@ -241,7 +241,7 @@ module ActiveRecord
if @reflection.options[:dependent] && @reflection.options[:dependent] == :destroy
destroy_all
- else
+ else
delete_all
end
@@ -520,8 +520,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"