Created
September 20, 2012 21:27
-
-
Save zhannes/3758455 to your computer and use it in GitHub Desktop.
sinatra/active-record configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### 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