My existing Hostmonster account did not support Rails 3. As Rails 3 is the only version of Rails with which I am familiar, I decided to try deploying in the cloud instead, and Heroku was the first name on Google. It’s free to get started (pricing kicks in when you want more of anything), and incredibly fast to deploy, even from Windows. Engine Yard seems to be another popular choice that I’ll take a look at later.
Heroku depends on Git, Aptana requires it (and installs its own version if you don’t have it), and Agile Development with Rails assumes the use of Git throughout. Git is clearly the Software Configuration Management (SCM) system of choice for a substantial segment of the RoR community – and that’s good enough for me.
Installing Git, and loading source onto Git
I installed Git when I installed Aptana Studio 3 – it is a prerequisite, and a version is included in the Aptana binary. I am not sure if there are pros / cons to using this included version versus installing from GitHub directly, but it has worked well for me thus far. If you still need to install Git, you can follow these instructions to install Git for Windows.
You’ll need to have a Git username and password set up – the example below is for user Adam Wible. You can do this by modifying your .gitconfig file, which typically goes in your home directory. The easier way is to do this automatically via the following commands in the Aptana shell:
$ git config –global user.name “Adam Wible”
$ git config –global user.email “firstname.lastname@example.org”
After this is set up, you should generate a public key, as this is necessary to publish code to the web via Git / Heroku:
$ ssh-keygen -t rsa -c “email@example.com”
More information here: http://help.github.com/win-set-up-git/
Press enter when it asks for the file in which to save the key (accept the default, in your home directory), and then enter a passphrase, twice.
Create an account on GitHub, remember the username you created. It will also generate an API key based on your password, which you can access in your account admin section.
Add public key to your GitHub account by pasting in the contents of:
Then test with:
This should give you the following message:
Hi [username]! You’ve successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
Navigate to the directory of the application you are deploying. Continue the Git configuration with the following shell commands based on the username and token you just created on GitHub. Again, the example below is for user Adam Wible:
$ git config –global github.user adamwible
$ git config — global github.token your_github_token
$ git init
$ git add .
$ git commit -m ‘first commit’
$ git remote add origin firstname.lastname@example.org:adamwible/your_application_name.git
$ git push -u origin master
With this you are ready to go – done, Adam Wible.
How to install Heroku
Make a new account online, confirm your email address
Install the heroku gem:
$ gem install heroku
$ heroku create
Login with the Heroku username and password you just created. Generate a public key (heroku couldn’t do it for me, so I did the SSH thing), make a passphrase, and you’re ready to go. Done – Adam Wible.
How to deploy using Heroku
heroku rake db:migrate (different than rake db:migrate)
heroku rake db:seed
Note that there is no reason to mess with the production database settings in the Gemfile and config/database.yml file because these are ignored by Heroku. Heroku will put you on a shared PostgreSQL database, for your own good.
If you want to rename (via the Heroku website interface), you’ll need to replace the existing heroku remote with an updated one:
$ git remote rm heroku$ git remote add heroku email@example.com:newname.git
And that’s it – Adam Wible.