0

我有一个rails 应用程序,我想用tenderlove 的文本使其可搜索。在控制台中它工作正常,但在我的应用程序中我收到如下错误:

/opt/local/lib/ruby/gems/1.8/gems/texticle-1.0.3/lib/texticle.rb:65:in `index'
/Users/vjmayr/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/named_scope.rb:92:in `call'
/Users/vjmayr/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/named_scope.rb:92:in `named_scope'
/Users/vjmayr/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/named_scope.rb:97:in `call'
/Users/vjmayr/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/named_scope.rb:97:in `search'
/Users/vjmayr/softwareclick/app/controllers/categories_controller.rb:12:in `search'

...

def search
          @allproducts = Product.search(params[:search], :conditions => ['category_id in (?)', @category.subtree_ids]) #line 12
        if params[:search]
           @products = Product.search(params[:search], :conditions => ['category_id in (?)', @category.subtree_ids]).paginate :per_page => 30, :page => params[:page] #line 14
         else
           @products = []
         end

         respond_to do |format|
           format.html # show.html.erb
           format.xml  { render :xml => @category }
         end
  end

有人可以指出问题的根源吗?我被困住了...

谢谢!

瓦尔

PS 关于第 12 行的奇怪之处在于,它不应该被使用,因为我在参数中进行了搜索....当我禁用它时,错误指的是第 14 行

4

1 回答 1

0

Try this:

Product.search(params[:search]).all :conditions => ...
# this also works
Product.search(params[:search]).paginate :conditions => ...

I hope it helps.

于 2011-05-23T18:14:18.467 回答