搜索效果很好,但排序不起作用。请帮帮忙?
@accounts1 = Account.search(params[:search])
@accounts = @accounts1.paginate(:order =>(sort_column + " " + sort_direction),
:per_page => 5,
:page => params[:accounts_page])
答案 0 :(得分:1)
如果你使用Rails 3+,你应该尝试这样的事情:
@accounts = Account.search(params[:search]).order("#{sort_column} #{sort_direction}").paginate(:page => params[:accounts_page], :per_page => 5)
search
方法来自哪里?