Question

Are there any alternatives to the Sequel ORM when working on a Sinatra-based app?

Was it helpful?

Solution

AFAIK, you are not forced to use Sequel with Sinatra. If you wish you can use Datamapper or an other ORM.

OTHER TIPS

You don't have to use Sequel with Sinatra. Sinatra is pretty agnostic.

If you are interested in using ActiveRecord its pretty straightforward: require 'rubygems' require 'sinatra' require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter => 'sqlite3',
  :database =>  'sinatra_application.sqlite3.db'
)

You can read more about ActiveRecord and Sinatra here. There is also a gem sinatra-activerecord that handles some of the boilerplate.

There is also the Ruby Object Mapper (rom-rb) which is a pretty nice implementation of the DataMapper pattern if you want something more fully featured than Sequel, but aren't interested in using ActiveRecord.

You might check out Padrino. It's a lightweight framework with a Sinatra core that supports several ORMs right out of the box.

You can use DataMapper or ActiveRecord, or just plain DBI. Sinatra does not have any integrated support for a specific ORM framework.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top