Commit 238eccbc authored by James Sapara's avatar James Sapara

updates to make this deployable

parent 73e3a7d1
...@@ -11,8 +11,14 @@ gem 'sinatra-activerecord' ...@@ -11,8 +11,14 @@ gem 'sinatra-activerecord'
gem 'puma' gem 'puma'
gem 'tux' gem 'tux'
# These gems are only installed when RACK_ENV is either `development` or `test`
group :development, :test do group :development, :test do
gem 'pry' gem 'pry'
gem 'shotgun' gem 'shotgun'
gem 'sqlite3' gem 'sqlite3'
end end
# These gems are only installed when RACK_ENV is `production`
group :production do
gem 'pg'
end
...@@ -24,6 +24,7 @@ GEM ...@@ -24,6 +24,7 @@ GEM
method_source (0.8.2) method_source (0.8.2)
minitest (5.8.3) minitest (5.8.3)
multi_json (1.11.2) multi_json (1.11.2)
pg (0.18.4)
pry (0.10.3) pry (0.10.3)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
...@@ -76,6 +77,7 @@ PLATFORMS ...@@ -76,6 +77,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
activesupport activesupport
pg
pry pry
puma puma
rake rake
...@@ -85,3 +87,6 @@ DEPENDENCIES ...@@ -85,3 +87,6 @@ DEPENDENCIES
sinatra-contrib sinatra-contrib
sqlite3 sqlite3
tux tux
BUNDLED WITH
1.12.1
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
get '/' do get '/' do
erb :index erb :index
end end
configure do configure do
# Log queries to STDOUT in development
if Sinatra::Application.development? case Sinatra::Application.environment
# Development database settings
when :development
# Log queries to STDOUT in development
ActiveRecord::Base.logger = Logger.new(STDOUT) ActiveRecord::Base.logger = Logger.new(STDOUT)
end set :database, {
adapter: "sqlite3",
database: "db/db.sqlite3"
}
# Test database settings
when :test
set :database, {
adapter: "sqlite3",
database: "db/test.sqlite3"
}
# Production database settings, tuned for heroku
when :production
db = URI.parse(ENV['DATABASE_URL']) # standard heroku environment variable for configuring the database
set :database, { set :database, {
adapter: "sqlite3", :adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
database: "db/db.sqlite3" :host => db.host,
} :username => db.user,
:password => db.password,
:database => db.path[1..-1],
:encoding => 'utf8'
}
else
raise ArgumentError("Expected RACK_ENV to be: development, test or production")
end
# Load all models from app/models, using autoload instead of require # Load all models from app/models, using autoload instead of require
# See http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html # See http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html
......
...@@ -8,15 +8,17 @@ require 'sinatra' ...@@ -8,15 +8,17 @@ require 'sinatra'
require 'sinatra/activerecord' require 'sinatra/activerecord'
require 'sinatra/contrib/all' # Requires cookies, among other things require 'sinatra/contrib/all' # Requires cookies, among other things
require 'pry'
ENV['RACK_ENV'] ||= 'development'
APP_ROOT = Pathname.new(File.expand_path('../../', __FILE__)) APP_ROOT = Pathname.new(File.expand_path('../../', __FILE__))
APP_NAME = APP_ROOT.basename.to_s APP_NAME = APP_ROOT.basename.to_s
# Sinatra configuration # Global Sinatra configuration
configure do configure do
set :root, APP_ROOT.to_path set :root, APP_ROOT.to_path
set :server, :puma set :server, :puma
set :environment, ENV['RACK_ENV'].to_sym
enable :sessions enable :sessions
set :session_secret, ENV['SESSION_KEY'] || 'lighthouselabssecret' set :session_secret, ENV['SESSION_KEY'] || 'lighthouselabssecret'
...@@ -24,6 +26,12 @@ configure do ...@@ -24,6 +26,12 @@ configure do
set :views, File.join(Sinatra::Application.root, "app", "views") set :views, File.join(Sinatra::Application.root, "app", "views")
end end
# Development and Test Sinatra Configuration
configure :development, :test do
require 'pry'
end
# Set up the database and models # Set up the database and models
require APP_ROOT.join('config', 'database') require APP_ROOT.join('config', 'database')
......
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