0
如何禁用ransack gem來搜索第一個請求中的所有記錄?禁用搜索全部搜索結果
我擁有數千條記錄,並且不希望每次訪問該頁面時都加載它們。我只想顯示搜索表單。
def index
@search = ransack_params
@users = ransack_result
end
private
def ransack_params
User.search(params[:q])
end
def ransack_result
@search.result(distinct: false)
end
我的控制檯的輸出顯示如下:
Processing by UsersController#index as HTML Parameters: {"utf8"=>"✓", "q"=>{"name"=>""}, "button"=>""}
Rendering users/index.html.erb within layouts/application
User Load (0.5ms) SELECT "users".* FROM "users"