Here is what I'm trying:
app/models/product.rb
class Product < ActiveRecord::Base
class << self
def searchlogic(conditions = {})
ProductSearch.new(self, scope(:find), conditions)
end
end
end
app/models/product_search.rb
require "se开发者_StackOverflow中文版archlogic/search"
class ProductSearch < SearchLogic::Search
include SearchLogic
def foobar
puts :hello_world
end
end
test
~/project $ script/console
>> @search = Product.searchlogic
NameError: uninitialized constant SearchLogic
What's the appropriate way to subclass or extend SearchLogic::Search
?
Considering there's not very much searchlogic help here on SO, I decided not to delete this question and instead answer it myself.
The Module name is Searchlogic
with a lowercase L
.
Here is the correct app/models/product_search.rb
class ProductSearch < Searchlogic::Search
include Searchlogic
def foobar
puts :custom_method
end
end
精彩评论