Commit 586d68f8 authored by James Sapara's avatar James Sapara

updates based on code review from @vaz

parent 0d03b51c
......@@ -11,14 +11,15 @@ gem 'sinatra-activerecord'
gem 'puma'
gem 'tux'
# These gems are only installed when RACK_ENV is either `development` or `test`
# These gems are only installed when run as `bundle install --without production`
group :development, :test do
gem 'pry'
gem 'shotgun'
gem 'sqlite3'
end
# These gems are only installed when RACK_ENV is `production`
# bundle install --without test --without development
group :production do
gem 'pg'
# uncomment to use postgres in production, or move outside a group if your app uses postgres for development and production
# gem 'pg'
end
......@@ -24,7 +24,6 @@ GEM
method_source (0.8.2)
minitest (5.8.3)
multi_json (1.11.2)
pg (0.18.4)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
......@@ -77,7 +76,6 @@ PLATFORMS
DEPENDENCIES
activesupport
pg
pry
puma
rake
......
configure do
case Sinatra::Application.environment
# Development database settings
when :development
# Log queries to STDOUT in development
configure :development do
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
configure :development, :test do
set :database, {
adapter: "sqlite3",
database: "db/db.sqlite3"
}
# Test database settings
when :test
set :database, {
adapter: "sqlite3",
database: "db/test.sqlite3"
adapter: 'sqlite3',
database: APP_ROOT.join('db', "#{Sinatra::Application.environment}.sqlite3")
}
# Production database settings, tuned for heroku
when :production
# Configure from a DATABASE_URL environment variable
end
configure :production do
db = URI.parse(ENV['DATABASE_URL']) # standard heroku environment variable for configuring the database
set :database, {
......@@ -28,15 +21,13 @@ configure do
:database => db.path[1..-1],
:encoding => 'utf8'
}
else
raise ArgumentError("Expected RACK_ENV to be: development, test or production")
end
end
configure do
# Load all models from app/models, using autoload instead of require
# See http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html
Dir[APP_ROOT.join('app', 'models', '*.rb')].each do |model_file|
filename = File.basename(model_file).gsub('.rb', '')
autoload ActiveSupport::Inflector.camelize(filename), model_file
end
end
......@@ -8,8 +8,6 @@ require 'sinatra'
require 'sinatra/activerecord'
require 'sinatra/contrib/all' # Requires cookies, among other things
ENV['RACK_ENV'] ||= 'development'
APP_ROOT = Pathname.new(File.expand_path('../../', __FILE__))
APP_NAME = APP_ROOT.basename.to_s
......@@ -17,7 +15,6 @@ APP_NAME = APP_ROOT.basename.to_s
configure do
set :root, APP_ROOT.to_path
set :server, :puma
set :environment, ENV['RACK_ENV'].to_sym
enable :sessions
set :session_secret, ENV['SESSION_KEY'] || 'lighthouselabssecret'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment