will_paginate -error-undefined method`total_pages'

Har*_*shi 6 ruby-on-rails will-paginate

我正在使用will_paginate"2.3.15"作为我的rails应用程序

在我的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>
Run Code Online (Sandbox Code Playgroud)

我的rails版本3.0.0和ruby版本1.8.7

请帮助

Adr*_*uio 4

为什么要添加:all? 从will_paginate wiki你可能应该使用:

@units = Unit.paginate(:page => params[:page], :order => 'created_at DESC')
Run Code Online (Sandbox Code Playgroud)