开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜