When I first started playing with rails back in 2006, deployment was a scary complex world that I avoided for some reason. And because I never deployed any production code I didn't learn anything about how difficult it was back then. But a lot has changed since 2006 and a few weeks ago I stumbled upon this rails hosting service called Heroku.
Heroku is labeled as a cloud based hosting service for rails based web applications. But that isn't saying much so I decided to deploy something myself and see just how easy or hard this would be. I soon found that deployment would never be this easy again. The steps below are exactly what I followed the first time I deployed a simple application to Heroku.
Commit your code locally with git
Init your git repository for the first time.
add every file in your project so we can commit.
git add .
commit your code to the local repository.
git commit -m 'first commit'
Install the heroku gem
Simply install the gem to get started with heroku.
gem install heroku
Setup your SSH keys
First verify that you don't already have a key generated.
If the above returns 'no such file or directory' you can simply generate your key
ssh-keygen -t rsa -C '[email protected]'
At the first prompt you can just hit enter to generate the key with the default name. At the next prompt you need to enter a good passphrase and confirm it.
Deploy your rails application to heroku
Type the command below and when prompted for credentials simply enter your username (usually your email) and password.
Next push your code up to heroku via git
git push heroku master
And finally run the rake command to get your database setup for the first time
heroku rake db:migrate
You should have a working application now! Just browse to your heroku url and check it out!
Now you can make changes to your app locally and push them up with a simple 'git push heroku' from the command line.