Skip to content

Instantly share code, notes, and snippets.

@epoch
Created August 1, 2016 00:43
Show Gist options
  • Select an option

  • Save epoch/83f58349d9722cadfc1f2794e7f64a3d to your computer and use it in GitHub Desktop.

Select an option

Save epoch/83f58349d9722cadfc1f2794e7f64a3d to your computer and use it in GitHub Desktop.
Heroku Deployment Guide

Heroku sinatra deploy guide

First some setup for our files, locally.

  1. Create a new file in the project root called Gemfile
  2. You must list the gems that your project uses in this file. example:
source 'https://rubygems.org'

gem 'activerecord'
gem 'sinatra'
gem 'pg'
gem 'bcrypt'
gem 'httparty'
gem 'pry'
  1. Make a config.ru file in the project root. This is the program heroku will run to start your app. It should look like the example below:
require './main'

run Sinatra::Application
  1. We need to gem install bundler, then enter the Bundler command in our terminal to build a gemlock file.

  2. Change your db_config.rb like below:

# existing code...


ActiveRecord::Base.establish_connection( ENV['DATABASE_URL'] || options)

Finally, comment out or delete your sinatra reloader require line, its not necessary on heroku.

This concludes our local file setup.

Heroku Stuff

Now we need to do the heroku stuff. Visit the link below:

Heroku deploy Guide

Follow the steps until we get to the database section, then click this link:

Addons for heroku

Install the heroku postgres addon.

follow the instructions again. heroku db

Now we need to actually create the table our app needs, but on heroku side.

type the following in console: heroku pg:psql

Lets make our table:

secure-caverns-28930::DATABASE=> create table events (
secure-caverns-28930::DATABASE(>   id serial4 primary key,
secure-caverns-28930::DATABASE(>   title varchar(100),
secure-caverns-28930::DATABASE(>   year integer,
secure-caverns-28930::DATABASE(>   plot varchar(500),
secure-caverns-28930::DATABASE(>   poster varchar(200),
secure-caverns-28930::DATABASE(>   imdb_id varchar(50)
secure-caverns-28930::DATABASE(> );

type heroku restart after we create the table.

Type git add -A, git commit -m "message" Finally, type git push heroku master. Hit heroku open to open the site in your browser.

Troubleshitting

heroku logs to see what's wrong heroku restart sometimes helps heroku create sometimes it's better to kill it with fire

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment