- 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::Base
and addinclude WillPaginate::Sinatra::Helpers
so that all views can usewill_paginate
- In controller,
@users = User.paginate(:page => params[:page], :per_page => 30)
- In view,
= will_paginate @users
will generate the pagers
If you want to style your pagers
- Include this css in your layout
- Style it