Skip to content
Browse files

Improve configuration

Sets the Activerecord configuration based on RACK_ENV, with
"development" as the default.
  • Loading branch information...
1 parent 3a61bdf commit 1f79ca6018b81ca23adaf9935fb9210d2138ffe2 @mistydemeo committed Aug 12, 2012
Showing with 7 additions and 2 deletions.
  1. +2 −2 app.rb
  2. +5 −0 config/config.rb
View
4 app.rb
@@ -6,14 +6,14 @@
require 'active_record'
require 'json'
+require "config/config"
+
require 'models/items'
require 'models/post'
require 'models/poster'
require 'helpers'
require 'preeventualist/brooklynt'
-set :database, "sqlite://db/preeventualist.db"
-
get "/" do
erb :homepage
end
View
5 config/config.rb
@@ -0,0 +1,5 @@
+RACK_ENV ||= ENV['RACK_ENV'] || 'development'
+set :environment, RACK_ENV.to_sym
+
+# Load db config and establish connection
+ActiveRecord::Base.establish_connection YAML.load(File.read(File.join(File.dirname(__FILE__), 'config', 'database.yml'))).with_indifferent_access[RACK_ENV]

0 comments on commit 1f79ca6

Please sign in to comment.
Something went wrong with that request. Please try again.