unable to combine sort order with searching in will_paginate
Searching works well but sorting is not working. Please help?
@accounts1 = Account.search(params[:search])
@accounts = @accounts1.paginate(:order =>(sort_column + " " + sort_directi开发者_如何学Con),
:per_page => 5,
:page => params[:accounts_page])
If you're using Rails 3+ you should try something like this:
@accounts = Account.search(params[:search]).order("#{sort_column} #{sort_direction}").paginate(:page => params[:accounts_page], :per_page => 5)
Where does the search
method come from?
精彩评论