mkdir config
touch environments.rb
- set up thusly:
configure :production, :development do
db = URI.parse(ENV['DATABASE_URL'] || 'postgres://brittlewis@localhost/[dbname_here]')
ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:host => db.host,
:username => db.user,
:password => db.password,
:database => db.path[1..-1],
:encoding => 'utf8'
)
end
- Make sure to require environments.rb in your sinatra server:
require_relative 'config/environments'
- and add this after block to the server file:
after do
ActiveRecord::Base.clear_active_connections!
end
touch config.ru
require './server'
run Sinatra::Application
touch Gemfile
- make it say:
source "https://rubygems.org"
ruby "2.0.0"
gem "sinatra", "~> 1.4"
gem "sinatra-contrib", "~> 1.4"
gem "activerecord", "~> 4.0"
gem "pg", "~> 0.17"
bundle install
- you should see Gemfile.lock created for you
- File in root folder of app used by heroku to establish process type. Not required.
- https://devcenter.heroku.com/articles/procfile#process-types-as-templates
- For sinatra:
web: bundle exec rackup config.ru -p $PORT
git init
git commit -m "first commit"
- create app
heroku apps:create thenameofmyapp
or...
heroku create
heroku pg:psql
- create table in database by running schema
heroku open