-
-
mkdir config -
touch config/environments.rb -
Set it up thusly:
configure :production, :development do db = URI.parse(ENV['DATABASE_URL'] || 'postgres://user@localhost/dbname') end ActiveRecord::Base.establish_connection( :adapter => 'postgresql', :host => db.host, :username => db.user, :password => db.password, :database => db.path[1..-1], :encoding => 'utf8' ) -
Make sure to include environments.rb in your server.rb
require_relative 'config/environments'
-
-
###Add this "after" to your main sinatra server…
after do ActiveRecord::Base.clear_active_connections! end -
###Create your config.ru file…
require './server' run Sinatra::Application -
###You need a Gemfile…
-
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 -
have you seen your nice Gemfile.lock?
-
-
web: bundle exec rackup config.ru -p $PORT
##3. Get Ready to Heroku##
-
git init -
git commit -m "first commit" -
create app with
heroku apps:create thenameofmyapporheroku create -
run schema migration
heroku pg:psql- create table in database by running schema
-
heroku openand feast your eyes!
Done! Let me know if there is anything missing.
found an errant "end" in my configure production/development block. fixed it as well as markdown formatting and updated gist.