Permalink
Browse files

Shold be using scope(:find) not proxy_options. So that we can pick up…

… all of the coptions for the current scope
  • Loading branch information...
1 parent baf5f33 commit ce7849bd1ec54e543bab38261b320757b07e889e @binarylogic committed Jan 22, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/searchlogic/named_scopes/or_conditions.rb
@@ -123,16 +123,16 @@ def create_or_condition(scopes, args)
scope = named_scope_options(scopes.first)
column_type = scope.respond_to?(:searchlogic_arg_type) ? scope.searchlogic_arg_type : :string
named_scope scopes.join("_or_"), searchlogic_lambda(column_type) { |*args|
- merge_scopes_with_or(scopes.collect { |scope| send(scope, *args) })
+ merge_scopes_with_or(scopes.collect { |scope| clone.send(scope, *args) })
}
end
def merge_scopes_with_or(scopes)
- scopes_options = scopes.collect { |scope| scope.proxy_options }
+ scopes_options = scopes.collect { |scope| scope.scope(:find) }
conditions = scopes_options.reject { |o| o[:conditions].nil? }.collect { |o| sanitize_sql(o[:conditions]) }
scope = scopes_options.inject(scoped({})) { |current_scope, options| current_scope.scoped(options) }
options = scope.scope(:find)
- options.delete(:readonly) unless scope.proxy_options.key?(:readonly)
+ options.delete(:readonly) unless scopes.any? { |scope| scope.proxy_options.key?(:readonly) }
options.merge(:conditions => "(" + conditions.join(") OR (") + ")")
end
end

0 comments on commit ce7849b

Please sign in to comment.