lib/search_cop.rb in search_cop-1.0.1 vs lib/search_cop.rb in search_cop-1.0.2

- old
+ new

@@ -58,12 +58,13 @@ def unsafe_search_cop(query, scope_name) return respond_to?(:scoped) ? scoped : all if query.blank? query_builder = QueryBuilder.new(self, query, search_scopes[scope_name]) - scope = search_scopes[scope_name].reflection.scope ? instance_exec(&search_scopes[scope_name].reflection.scope) : eager_load(query_builder.associations) + scope = instance_exec(&search_scopes[scope_name].reflection.scope) if search_scopes[scope_name].reflection.scope + scope ||= eager_load(query_builder.associations) if query_builder.associations.any? - scope.where query_builder.sql + (scope || self).where(query_builder.sql) end end end