以下是我正在尝试的内容:
class Product < ActiveRecord::Base
class << self
def searchlogic(conditions = {})
ProductSearch.new(self, scope(:find), conditions)
end
end
end
require "searchlogic/search"
class ProductSearch < SearchLogic::Search
include SearchLogic
def foobar
puts :hello_world
end
end
~/project $ script/console
>> @search = Product.searchlogic
NameError:未初始化的常量SearchLogic
对SearchLogic::Search
进行子类化或扩展的适当方法是什么?
答案 0 :(得分:0)
考虑到SO的搜索逻辑帮助不多,我决定不删除这个问题,而是自己回答。
模块名称为Searchlogic
,小写L
。
这是正确的app/models/product_search.rb
class ProductSearch < Searchlogic::Search
include Searchlogic
def foobar
puts :custom_method
end
end