[Rails 常用插件简介]will_paginate

[Rails 常用插件简介]will_paginate

Rails2.0中原pagination将被移出作为插件classic_pagination,will_paginate是个非常不错的替代方案

一:安装

[Copy to clipboard] [ - ]
加入收藏了,要用时就取出来用!
即是现在不能直接用pagination了?
目前可以的:)
@posts = Post.paginate_by_board_id @board.id, :page => params[:page]||1
这样有点不太对吧?报错

看railscast的视频,这样没错
@products = Product.paginate :per_page => 1, :page => params[:page]
引用:
原帖由 blackanger 于 2007-9-5 17:28 发表
@posts = Post.paginate_by_board_id @board.id, :page => params[:page]||1
这样有点不太对吧?报错

看railscast的视频,这样没错
@products = Product.paginate :per_page => 1, :page => params[:page]
说明一下retuning,在rails的core-ext object中

[Copy to clipboard] [ - ]
@products = Product.paginate_by_board_id @board.id,:page => params[:page]||1
我这样就会出错了
RuntimeError in AdminController#list

Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

rails报的错也挺有意思阿,人性化
RuntimeError in AdminController#list

I can't make sense of find_by_board_id

[ 本帖最后由 blackanger 于 2007-9-5 19:31 编辑 ]
引用:
Called id for nil
明白你的意思了,我也不是和你探讨谁对谁错。。。有点不明白那个board,现在明白了