Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

satisfy heroku demands

  • Loading branch information...
commit 51f39a0b86f10b4f1ba7a2e4f4ed25c50d24199d 1 parent 2fb487f
@netzfisch authored
Showing with 21 additions and 2 deletions.
  1. +2 −0  Gemfile.lock
  2. +1 −1  config/database.yml
  3. +18 −1 models/participant.rb
View
2  Gemfile.lock
@@ -35,6 +35,7 @@ GEM
i18n (0.6.9)
minitest (4.7.5)
multi_json (1.8.4)
+ pg (0.17.1)
rack (1.5.2)
rack-protection (1.5.2)
rack
@@ -82,6 +83,7 @@ DEPENDENCIES
autotest-inotify
autotest-standalone
haml
+ pg
rspec
sinatra
sinatra-activerecord
View
2  config/database.yml
@@ -7,5 +7,5 @@ test:
database: db/test.sqlite3
production:
- adapter: postgresql
+ adapter: pg
database: production
View
19 models/participant.rb
@@ -1,9 +1,26 @@
require 'sinatra/activerecord'
+require 'active_record'
-configure do
+configure :development do
# connect to the database
dbconfig = YAML.load(File.read('config/database.yml'))
ActiveRecord::Base.establish_connection dbconfig['development']
+
+ begin
+ ActiveRecord::Schema.define do
+ create_table :participants do |t|
+ t.string :name, :null => false, :limit => 100
+ t.string :email, :null => false, :limit => 50
+ end
+ end
+ rescue ActiveRecord::StatementInvalid
+ # do nothing - gobble up the error
+ end
+end
+
+configure :production do
+ ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'] || 'postgres://localhost/mydb')
+
begin
ActiveRecord::Schema.define do
create_table :participants do |t|
Please sign in to comment.
Something went wrong with that request. Please try again.