以下是我正在尝试的:
app/型号/Product.rb
class Product < ActiveRecord::Base
class << self
def searchlogic(conditions = {})
ProductSearch.new(self, scope(:find), conditions)
end
end
endapp/models/Productsearch.rb
require "searchlogic/search"
class ProductSearch < SearchLogic::Search
include SearchLogic
def foobar
puts :hello_world
end
end测试
~/project $ script/console
>> @search = Product.searchlogicNameError:未初始化的常数SearchLogic
子类或扩展SearchLogic::Search的适当方法是什么?
发布于 2010-09-04 07:26:33
考虑到这里没有太多的搜索逻辑帮助,所以我决定不删除这个问题,而是自己回答它。
模块名为Searchlogic,带有小写的L。
这是正确的app/models/product_search.rb
class ProductSearch < Searchlogic::Search
include Searchlogic
def foobar
puts :custom_method
end
endhttps://stackoverflow.com/questions/3641286
复制相似问题