`
wenke
  • 浏览: 77229 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

use will_paginate for rails

    博客分类:
  • ror
阅读更多
It's pretty simple for paginate of rails when used gem will_paginate

  1、instatl gem will_paginate
    sudo gem install will_paginate

  2、create a rails project
    rails blog
    cd blog
    ./script/server
    in browser enter http://localhost:3000
    OK......

  3、use scaffold generate template
    ./script/generate scaffold post name:string
    use gedit open app/PostController
    add require 'will_paginate' before class name
    change action index code
    #@posts = Post.find(:all)
    @posts = Post.paginate :page => params[:page], :per_page => 5

     #/posts/index.html.erb
     add <%= will_paginate @posts %>

  4、in browser entry http://localhost:3000/posts, create two new post will show paginate

  5、that's it, is pretty simple?
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics