提交 27be7778 编写于 作者: A Aaron Patterson

avoid a hash lookup

上级 e66bf6f5
......@@ -1962,13 +1962,13 @@ def construct(parent, associations, joins, row)
construct(parent, association, joins, row)
end
when Hash
associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name|
associations.sort_by { |k,_| k.to_s }.each do |name, assoc|
join = joins.detect{|j| j.reflection.name.to_s == name.to_s && j.parent_table_name == parent.class.table_name }
raise(ConfigurationError, "No such association") if join.nil?
association = construct_association(parent, join, row)
joins.delete(join)
construct(association, associations[name], joins, row) if association
construct(association, assoc, joins, row) if association
end
else
raise ConfigurationError, associations.inspect
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册