我在我的Rails应用程序中使用will_paginate“2.3.15”
在我的units_controller.rb中
def index
@units = Unit.paginate(:all ,:page => params[:page], :order => 'created_at DESC')
end
in my views(index)
<%= will_paginate(@units)%>
but it gives error
undefined method `total_pages' for #<ActiveRecord::Relation:0xb523dc>
我的Rails版本3.0.0
和 ruby 版本1.8.7
请帮助
最佳答案
为什么添加:all
?
在will_paginate wiki中,您可能应该使用:
@units = Unit.paginate(:page => params[:page], :order => 'created_at DESC')
关于ruby-on-rails - will_paginate-错误未定义的方法 `total_pages',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6356062/