searchlogic icon indicating copy to clipboard operation
searchlogic copied to clipboard

Support for scope return by model class method

Open speedmax opened this issue 15 years ago • 0 comments

is there any chance that searchlogic will support class method that returns a scope or ActiveRecord::Relation.

They both support chainable lazily queries, this is better to construct more complex name scopes that has parameters, (default param value in a lambda is pain between Ruby 1.8/1.9)

example

# Rails 2
class Task < ActiveRecord::Base
  # scopes
  def self.completed
    scoped(:conditions => {:status => 'completed'})
  end
end

# Rails 3
class Task < ActiveRecord::Base
  # scopes
  def self.completed
    where(:status => 'completed')
  end
end

speedmax avatar Mar 24 '10 23:03 speedmax