提交 e70da0e1 编写于 作者: A Aaron Patterson

make sure scope_chain_items has consistent types

上级 9eb0cd28
......@@ -97,22 +97,24 @@ def join_to(manager)
constraint = build_constraint(reflection, table, key, foreign_table, foreign_key)
scope_chain_items = scope_chain[i]
scope_chain_items = scope_chain[i].map do |item|
if item.is_a?(Relation)
item
else
ActiveRecord::Relation.new(reflection.klass, table).instance_exec(self, &item)
end
end
if reflection.type
scope_chain_items += [
scope_chain_items.concat [
ActiveRecord::Relation.new(reflection.klass, table)
.where(reflection.type => foreign_klass.base_class.name)
]
end
scope_chain_items += [reflection.klass.send(:build_default_scope)].compact
scope_chain_items.concat [reflection.klass.send(:build_default_scope)].compact
constraint = scope_chain_items.inject(constraint) do |chain, item|
unless item.is_a?(Relation)
item = ActiveRecord::Relation.new(reflection.klass, table).instance_exec(self, &item)
end
if item.arel.constraints.empty?
chain
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册