First some setup for our files, locally.
- Create a new file in the project root called
Gemfile - 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'
- Make a
config.rufile 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
-
We need to
gem install bundler, then enter theBundlercommand in our terminal to build a gemlock file. -
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.
Now we need to do the heroku stuff. Visit the link below:
Follow the steps until we get to the database section, then click this link:
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.
heroku logs to see what's wrong
heroku restart sometimes helps
heroku create sometimes it's better to kill it with fire