Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't define block, just yield if block is given.

  • Loading branch information...
commit d9f199e1238a723432a2005c405fc5ae22dea24b 1 parent fdb7f84
@miloops miloops authored
View
14 activerecord/lib/active_record/associations/association_collection.rb
@@ -26,10 +26,10 @@ def initialize(owner, reflection)
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 @@ def build(attributes = {}, &block)
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 @@ def delete_all
reset_target!
reset_named_scopes_cache!
end
-
+
# Calculate sum using SQL, not Enumerable
def sum(*args)
if block_given?
@@ -241,7 +241,7 @@ def clear
if @reflection.options[:dependent] && @reflection.options[:dependent] == :destroy
destroy_all
- else
+ else
delete_all
end
@@ -520,8 +520,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"
Please sign in to comment.
Something went wrong with that request. Please try again.