will_paginateメモ

1. install
gemなら

gem install will_paginate

pluginなら(2009-01-03: Modified.)

script/plugin install svn://errtheblog.com/svn/plugins/will_paginate ← not recommended.
script/plugin install git://github.com/mislav/will_paginate.git

2. app/controllers/some_controller.rb

@models = Model.paginate(:page => params[:page],
                   #     :conditions => ["is_confirmed = ?", "0"],
                         :order => "updated_at asc",
                         :per_page => 15)

他にも色々とオプションあり。


3. app/views/foo/bar.html.erb

<div class="apple_pagination">
  <div clas="page_info"><%= page_entries_info @models %></div>
  <%= will_paginate @models, :container => false %>
</div>

will_paginateメソッドだけなら:classを渡す(+= "container => true")手もあり。


4. public/stylesheets
/usr/(local/)?lib/ruby/gems/1.8/gems/will_paginate-2.2.2/examplesにpagination.cssがあるのでそれをコピると楽。