Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use scoped here to get the scoped where

  • Loading branch information...
commit 0a7b481903b30fb8f533afb2bcc0e6dc202033fc 1 parent c91605b
@spastorino spastorino authored
View
8 activerecord/lib/active_record/associations/association_collection.rb
@@ -493,11 +493,9 @@ def create_record(attrs)
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?
Please sign in to comment.
Something went wrong with that request. Please try again.