Quick Overview of Deploying a Rails App to Heroku

Sometimes you’re working your way through Michael Hartl’s Rails Tutorial and you have just finished chapter 2 when something urgent commands your attention. It continues to command your attention for like a full week and then you decide to get back to it. Chapter 3 hits and Hartl’s telling you to deploy your app to Heroku, with no other explicit instructions except to repeat what you did last time. But it’s been a week, and you have no idea.

You could even say you’ve been derailed.

(*crickets*)

You’d really like to just get a move on with this, and don’t want to read the whole damn book again. Not that it wasn’t delightful to read the first time. So what are you going to do? Sit around until someone explicitly writes a blog post telling you what to do?

Anyway, I wrote you a nice little guide on how do deploy a rails app to Heroku. No frills. No answering questions like “Why do you do that?” or “What’s the mac version of this command?”  (I’m on a Windows machine, by the way) or “Where do babies come from?”.  Nope.  Just a quick checklist.

Because you need it.

Because you want it.

Because if it makes your life that much easier, it was worth skimming reading this dumb intro paragraph.

monty python

Okay, you don’t have to be so pushy!

  1. On your command line, navigate (cd) into folder you want to create the app folder in (workspaces, in the case of Hartl’s)
  2. Command line: rails _4.2.1_ new name_of_app
    • replace “4.2.1” with the version number in use, obviously
    • can check which version of rails you have by using the command rails -v
  3. The command line will do a bunch of things and then will be done
  4. Go to folder (GUI, not command line) and check that it’s been populated
  5. Open gemfile and make sure it has everything you need
  6. Command line: bundle install (or, apparently, just bundle will work, too.
    • can leave out groups by appending with --without group
  7. bundle update
  8. Push to git repository
    git init
    git add -A
    git commit -a "Initialize repository"
  9. Hartl recommends changing readme file from rdoc to md by going:
    git mv README.rdoc README.md
  10. Create a new repository in bitbucket or github or where-ever
  11. push your repository up to service
    git remote add origin git@bitbucket.org:<username>/app_name.git
    git push -u origin --all
  12. Get a basic “hello world” page up by:
    • go to app folder within the folder created for app_name
    • go to app > controllers > application controllers and open that file
    • add the lines:
      def hello
      render text: "hello, world!"
      end
  13. Save that file then go to the config folder from the root app folder and edit the “routes” file
  14. uncomment the root route line and add 'controller#hello' instead of "welcome#index"
  15. save that file
  16. commit changes by: git commit -am "Add hello"
  17. Push to heroku
    heroku create
    git push heroku master
  18. Your silly app is now on heroku slash the web

Well now you’ve got a killer one-page app on Heroku that just says “Hello, world!”. *clapping hands emoji*  Congrats! Now stop getting distracted so easily and get to it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s