简体   繁体   English

无法将排序顺序与在will_paginate中搜索相结合

[英]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_direction),
                                :per_page => 5,
                                :page => params[:accounts_page])

If you're using Rails 3+ you should try something like this: 如果您使用的是Rails 3+,则应尝试以下操作:

@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? search方法从何而来?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM