0

这是我正在尝试的:

应用程序/模型/product.rb

class Product < ActiveRecord::Base
  class << self
    def searchlogic(conditions = {})
      ProductSearch.new(self, scope(:find), conditions)
    end
  end
end

应用程序/模型/product_search.rb

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

4

1 回答 1

0

考虑到这里没有太多关于 SO 的 searchlogic 帮助,我决定不删除这个问题,而是自己回答。

模块名称是Searchlogic小写的L

这里是正确的app/models/product_search.rb

class ProductSearch < Searchlogic::Search

  include Searchlogic

  def foobar
    puts :custom_method
  end

end
于 2010-09-04T07:26:33.777 回答