Passing arguments to scope_procedure in searchlogic

Posted by Greg on Stack Overflow See other posts from Stack Overflow or by Greg
Published on 2010-04-30T18:51:45Z Indexed on 2010/05/03 19:38 UTC
Read the original article Hit count: 223

I'd like to use searchlogic's scope_procedure feature like so

class MyModelObject < ActiveRecord::Base
   scope_procedure :my_scope_proc, lambda { |p1, p2| { :conditions => "p1 >= #{p1} AND p2 < #{p2}" }}
end

Then, I am doing the search:

scope = MyModelObject.search(:my_scope_proc => true)
scope.all

The above code obviously doesn't work because I didn't pass p1 and p2 parameters to my named scope.

I can't figure out how to pass parameters to the named scope.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about searchlogic