aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-09-05 20:26:24 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2010-09-05 20:30:43 -0300
commit0a7b481903b30fb8f533afb2bcc0e6dc202033fc (patch)
treecbe306ef06d6430e509f4b8c98b393a9a62ded2a /activerecord
parentc91605b15b042f6559eab71888fb679ddae4c539 (diff)
downloadrails-0a7b481903b30fb8f533afb2bcc0e6dc202033fc.tar.gz
rails-0a7b481903b30fb8f533afb2bcc0e6dc202033fc.tar.bz2
rails-0a7b481903b30fb8f533afb2bcc0e6dc202033fc.zip
Use scoped here to get the scoped where
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 132e9cf882..1221a56bbc 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -493,11 +493,9 @@ module ActiveRecord
attrs.update(@reflection.options[:conditions]) if @reflection.options[:conditions].is_a?(Hash)
ensure_owner_is_not_new
- _scope = self.construct_scope[:create]
- csm = @reflection.klass.send(:current_scoped_methods)
- options = (csm.blank? || !_scope.is_a?(Hash)) ? _scope : _scope.merge(csm.where_values_hash)
-
- record = @reflection.klass.send(:with_scope, :create => options) do
+ scoped_where = scoped.where_values_hash
+ create_scope = scoped_where ? construct_scope[:create].merge(scoped_where) : construct_scope[:create]
+ record = @reflection.klass.send(:with_scope, :create => create_scope) do
@reflection.build_association(attrs)
end
if block_given?