1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use scoped here to get the scoped where

This commit is contained in:
Santiago Pastorino 2010-09-05 20:26:24 -03:00
parent c91605b15b
commit 0a7b481903

View file

@ -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?