fbpx
Getting Started with Heroku — deploying a Rails application

DATE

Have you ever been in search for an easy to follow list of instructions tailored to beginner devs? A lot of the tutorials I come across are so flooded with jargon — so I decided to start publishing my own notes for common tools.

A couple assumptions that I make:

  1. You’ve got an active account with Heroku. (https://signup.heroku.com/)
  2. You’ve got the Heroku CLI installed. (https://devcenter.heroku.com/articles/heroku-cli)

Do those things first! Don’t pass go!

Here are the instructions that I follow whenever pushing a new Rails App to Heroku. (but when in doubt — read the logs)

Within the root directory:

In your command line run:

Heroku Create

this creates an heroku repo for you with random name.

To push specific branch:

Run

git push heroku [branch_name]:master

OR to push MASTER run,

git push heroku master

To push your database to Heroku run,

Heroku run rake db:migrateHeroku run rake db:seed

To push ANY change:

Make the change then run,

Bundle installHeroku local

this checks your heroku connection

Git add .Git commit -m “Demo”Git push heroku masterHeroku open

To see all changes:

Heroku logs

Custom Fonts in Rails

When I initially pushed my app to Heroku my fonts weren’t working (OH NO!) I love custom fonts, and there was no way that I’d stick with the standard fonts. NOTE: the fonts I used were from Google.

In development mode I had the following code in my application.css.scss file:

@import url('//fonts.googleapis.com/css?family=[FONT+NAME]

This didn’t work when I pushed up to Heroku.

My hacky workaround was to include the following in my application.html.css file:

<%= stylesheet_link_tag( '//fonts.googleapis.com/css?family=[FONT+NAME]' ) %>

Thank you for reading!

More
articles

Stay up to date with me!

Sign up for resources, tips, and the occasional freebie.