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

时间:2011-05-06 08:25:13

标签: ruby-on-rails ruby-on-rails-plugins

搜索效果很好,但排序不起作用。请帮帮忙?

@accounts1 = Account.search(params[:search])
@accounts = @accounts1.paginate(:order =>(sort_column + " " + sort_direction),
                                :per_page => 5,
                                :page => params[:accounts_page])

1 个答案:

答案 0 :(得分:1)

如果你使用Rails 3+,你应该尝试这样的事情:

@accounts = Account.search(params[:search]).order("#{sort_column} #{sort_direction}").paginate(:page => params[:accounts_page], :per_page => 5)

search方法来自哪里?