>> User.all.class
=> Array
>> User.开发者_如何学JAVApaginate(:page => 1).class
TypeError: can't convert nil into Array
not work, but
>> User.all.class
=> Array
>> User.all.paginate(:page => 1).class
=> WillPaginate::Collection
seems OK and
def index
@title = "All users"
@users = User.all.paginate(:page => params[:page])
end
this right?
If you are using the "will paginate" gem, this following code should work for you.
def index
@title = "All users"
@users = User.paginate page => params[:page], :per_page => 10
end
精彩评论