Chris Mendez in For Developers, Ruby

Ruby Sinatra

Rails is wonderful but if you're new to web development, I suggest you give Sinatra a try first. Not only is it excellent for building small web apps, concepts such as routing are much easier to understand and learn.

Sinatra Framework

Install Sinatra Framework

gem install sinatra


DataMapper is broken up into the core library, dm-core, various database adapters and a number of optional libraries collectively:

Install everything:

gem install data_mapper

Install things piece by piece:

DataMapper core

gem install dm-core


require 'dm-constraints'


require 'dm-migrations'

Pick a database adapter:

gem install do_mysql

gem install do_postgres

gem install dm-sqlite-adapter


sudo gem install Haml

Example File

This file model.rb starts with

require 'rubygems'
require 'dm-core'
#require 'dm-constraints'
require 'dm-migrations'
require 'sinatra'  
require 'sinatra/reloader' if development?$stdout, :debug)
DataMapper.setup(:default, 'mysql://localhost/ruby_shortner')


Reloader is great for restarting your computer every time you make a file edit.

 gem install sinatra-contrib

Add this to index.rb

require 'sinatra'
require 'sinatra/reloader' if development?