- Add
gem 'will_paginate', '~> 3.0'to Gemfile - Add
%w(will_paginate will_paginate/active_record).each {|lib| require lib}to config.ru - Assuming modular Sinatra, open
Sinatra::Baseand addinclude WillPaginate::Sinatra::Helpersso that all views can usewill_paginate - In controller,
@users = User.paginate(:page => params[:page], :per_page => 30) - In view,
= will_paginate @userswill generate the pagers
If you want to style your pagers
- Include this css in your layout
- Style it
.digg_pagination
= will_paginate @notifications
Another document even original document does not include instruction to add the following command.
include WillPaginate::Sinatra::HelpersYou save me 2 hours.