Commit 7387e804 authored by Vaz Allen's avatar Vaz Allen

Use RACK_ENV as usual instead of hard-coded db

parent 3a81fa16
...@@ -2,20 +2,6 @@ require 'rake' ...@@ -2,20 +2,6 @@ require 'rake'
require "sinatra/activerecord/rake" require "sinatra/activerecord/rake"
require ::File.expand_path('../config/environment', __FILE__) require ::File.expand_path('../config/environment', __FILE__)
Rake::Task["db:create"].clear
Rake::Task["db:drop"].clear
# NOTE: Assumes SQLite3 DB
desc "create the database"
task "db:create" do
touch 'db/db.sqlite3'
end
desc "drop the database"
task "db:drop" do
rm_f 'db/db.sqlite3'
end
desc 'Retrieves the current schema version number' desc 'Retrieves the current schema version number'
task "db:version" do task "db:version" do
puts "Current version: #{ActiveRecord::Migrator.current_version}" puts "Current version: #{ActiveRecord::Migrator.current_version}"
......
ENV['RACK_ENV'] ||= 'development'
DATABASE_PATH = APP_ROOT.join('db', "#{ENV['RACK_ENV']}.sqlite3")
configure do configure do
# Log queries to STDOUT in development # Log queries to STDOUT in development
if Sinatra::Application.development? if Sinatra::Application.development?
...@@ -6,7 +9,7 @@ configure do ...@@ -6,7 +9,7 @@ configure do
set :database, { set :database, {
adapter: "sqlite3", adapter: "sqlite3",
database: "db/db.sqlite3" database: DATABASE_PATH
} }
# Load all models from app/models, using autoload instead of require # Load all models from app/models, using autoload instead of require
......
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