处理默认记录集返回的最佳方法是什么?如果没有返回搜索结果。目前使用下面的代码,但感觉不是正确的方法。
def self.search(params)
puts "SEARCH PARAM ="
puts params
if params
tire.search(load: true, page: params[:page], per_page: 20, :default_operator => 'AND', :use_dis_max => true) do
query do
boolean do
must { string 'gamers:2' } if params[:gamers] == "2"
must { string 'gamers:4' } if params[:gamers] == "4"
end
end
to_curl
end
else
puts "search params not found"
@gamers = Gamers.where(:level => "rookie")
end
end