Skip to content

Instantly share code, notes, and snippets.

@zhannes
Created September 20, 2012 21:27
Show Gist options
  • Save zhannes/3758455 to your computer and use it in GitHub Desktop.
Save zhannes/3758455 to your computer and use it in GitHub Desktop.
sinatra/active-record configs
##### Gemfile
gem 'sinatra-activerecord'
...
group :development, :test do
gem 'sqlite3'
# gem 'mysql2', '0.3.11'
end
##### Rakefile
require 'sinatra/activerecord/rake'
require './app'
###########
### app.rb file
require "sinatra/activerecord"
...
# MODEL DEFS
class User < ActiveRecord::Base ; end
class MyApp < Sinatra::Base
# PORT OF AR FOR SINATRA, ALLOWS MIGRATIONS YAY
register Sinatra::ActiveRecordExtension
#ENV CONFIGS
configure do
set :app_file, __FILE__
set :port, ENV['PORT'] || 4567
set :database, 'sqlite:///foo.db'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment