diff options
author | José Valim <jose.valim@gmail.com> | 2010-06-24 20:19:19 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-24 20:19:19 +0200 |
commit | 73682d016c2fff0b92ddb950efb25e80b07c716f (patch) | |
tree | fdeede2d9216fcb5bdd67246e426114974422f12 /activerecord/lib/active_record/associations | |
parent | 67ee6c38b9b112eabe37d5869c23210b9ebf453c (diff) | |
parent | 4b5f417e63e4cdd7fd6837c10ebaa9dd4860f55e (diff) | |
download | rails-73682d016c2fff0b92ddb950efb25e80b07c716f.tar.gz rails-73682d016c2fff0b92ddb950efb25e80b07c716f.tar.bz2 rails-73682d016c2fff0b92ddb950efb25e80b07c716f.zip |
Merge remote branch 'miloops/fixes'
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 14 |
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" |