I'm new to Sinatra and I want to use it together with Active Record and Will Paginate. After hours searching, I've finally found out to use active_record and will_paginate for non Rails application. Before I explain use Active Record and Will Paginate for non-Rails app, I assume that you use bundler and your database migration is already setup and working.

Step 1. Gemfile
First thing first, edit your Gemfile.
# Gemfile
source :rubygems
gem 'sinatra', '1.0.0', :require => 'sinatra/base'
gem 'activerecord', '3.0.0.rc', :require => 'active_record'
gem 'haml'
gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git',
:tag => 'v3.0.pre2',
:require => 'will_paginate/finders/base'

Step 2. Edit Your Model
You must extend your class model with Will Paginate module.
# your_model.rb
class Article < ActiveRecord::Base
extend WillPaginate::Finders::Base
Step 3. Edit your Sinatra Application Because Will Paginate helper does not work with Sinatra Application, so you need to write your own helper.
# your_sinatra_app.rb
require 'rubygems'
require 'bundler/setup'
Bundler.require :default
require 'your_model.rb'

class Application < Sinatra::Base
get '/' do
@articles = Article.order("created_at desc").
paginate :page => params[:page], :per_page => 10
haml :articles

helpers do
# helper for pagination
def paginate(resources)
if !resources.next_page.nil? and !resources.previous_page.nil?
html = "« Prev "
html += "#{params[:page]} of #{resources.total_pages} "
html += "Next »"
elsif !resources.next_page.nil? and resources.previous_page.nil?
html = "Next »"
elsif resources.next_page.nil? and !resources.previous_page.nil?
html = "« Prev "
html += "#{params[:page]} of #{resources.total_pages}"
return html
Step 4. Edit Your View
# views/articles.haml
Article list
- @articles.each do |article|
= article.title
= article.content
= article.author
= paginate @articles
Done. Sinatra, Will Paginate, and Active Record are ready to use. Note: The above code is extracted from my Sinatrails project, feel free to use it.

Here is an update for step 3: