我在我的 rails 3 应用程序上使用 meta_search。默认情况下(在按下搜索按钮之前)meta_search 返回搜索模型的所有元素。我想在用户按下搜索按钮或搜索参数为空之前设置 0 结果。
我使用 meta_search 如下:
def index
@search = Article.search(params[:search])
if params[:search].blank?
@places = nil
else
@places = @search.all
end
end
如果搜索参数为空,设置 0 结果的最佳方法是什么?
谢谢