开发者

1railstutorial.org 10.3.3 Pagination error?

>> 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜