searchlogic
searchlogic copied to clipboard
order helper & pagination
my rails have strange behavior if I use order helper.
my controller: def index @search = User.search(params[:search]) @users = @search.paginate(:page => params[:page], :per_page => 40) end
- Scenario 1: multiple order helper my view: order @search, :by => :name, :as => "username" order @search, :by => :created_at, :as => "Join" will_paginate @users
If I click "username", the result is correct, ascend_by_name, but the "next" link of will_paginate helper will produce: http://localhost:3000/users?page=2&search[order]=ascend_by_created_at
- Scenario 2: Single Order helper my view: order @search, :by => :name, :as => "username" will_paginate @users
If I click "username", the result is correct too, ascend_by_name, but the "next" link of will_paginate helper will produce: http://localhost:3000/users?page=2&search[order]=descend_by_name