当我提供特定的参数时,为什么太阳黑子会返回所有结果?

时间:2015-05-14 20:43:05

标签: ruby-on-rails sunspot sunspot-rails

我关注:Railscasts 278并拥有以下内容:

 def search 
    if params[:search] == ''
      @search_results = []
    else
      @search = Challenge.search do
        fulltext params[:search]
      end
      @search_results = @search.result
    end
  end

模型

 searchable do 
    text :title, :location, :boost => 5
    text :location
    time :created_at
    string :most_participated
  end

  def most_participated
    Participation.group('challenge_id').order('COUNT(challenge_id) DESC')
  end 

我的问题是,当我搜索特定内容时,我返回了所有记录。我的日志在这里提供:

  

开始GET" /搜索?utf8 =%E2%9C%93& search = Test"对于127.0.0.1 at   2015-05-14 21:39:15 +0100由ChallengesController处理#search as   HTML参数:{" utf8" =>"✓","搜索" =>"测试"}用户负载(0.4ms )   SELECT users。* FROM users WHERE usersid = 2 ORDER BY   usersid ASC限制1挑战加载(0.6ms)SELECT   challenges。* FROM challenges呈现挑战/ search.html.erb   在布局/应用程序内(10.6ms)

更新

任何坚持这一点的人。不要ClassName.search由于某些未知原因它不起作用。所以我做了Sunspot.search(User) do ...轨道广播已经过时了

0 个答案:

没有答案