安裝

Edit Gemfile

gem 'will_paginate'

使用

Controller Code

Example

@posts = @board.posts.paginate(:page => params[:page], :per_page => 2 )

 

View Code

Example

<%= will_paginate @posts, :previous_label => '上頁', :next_label => '下頁', :page_links => true %>

 

Model Code

Example

class Post
  self.per_page = 10
end

 

 

AwEi 發表在 痞客邦 PIXNET 留言(0) 人氣()