Monday, June 02, 2008

Heroku makes Ruby on Rails Deployment a really fun task!


I am a hobbyist programmer. Folks who like to develop stuff just for fun and not for a living. Ruby on Rails is the hottest new kid on the block that promises faster and easier development of dynamic web applications. Imbibed on ideas of DRY (Don't repeat yourself) and a sound MVC framework, It is probably the easiest to get started for hobbyist programmers.
Few weeks back ..I wrote about Getting started with Rails on Linux.

Once you have finished development on your local machine, the next logical step is to host it online. As a hobbyist, I started looking at some cheap hosting plans. I also stumbled upon some free hosts like vlexo. I got an account a week back and I still haven't managed to get it successfully hosted. So many configurations to manage, limitations on plugins etc.

I was about to give up and that's when I remembered Heroku. I had tried it months back courtesy of an invite from Techcrunch. I have to admit, initially I was pessimistic about the usefulness of an application that lets you edit, host and manage a Rails application all using a web interface. A Y Combinator startup built on Amazon EC2, Heroku is the best thing that happened for beginners and hobbyist who want to start their Rails journey.

Heroku boasts of tonnes of really great features. Ability to manage multiple apps, export and import apps, on the fly editing of code, a Rake and rails console, ability to add external gems and plugins, and an ability to work locally on your maching using their API and Git. Heroku also takes care of the scalability issues and has a inbuilt database and logs viewer. I could go on and on but it should be enough for beginners who are looking to run and deploy their first app. To try out Heroku, I deployed a simple application TaleWiki which was imported from a local copy.


Some tips for beginners:
1. If you are using and older version of Rails (pre 2.0), dynamic scaffolding and pagination won't work on the latest version of Rails running on Heroku. You'll need will_pagination or classic_pagination plugins. Watch railscast on using it. Classic_pagination is not available in Heroku's plugins list but can be downloaded from here.

2. If you are using the authenticate methods in Rails, do remember to add the following in your config/environment.rb file

config.action_controller.session = { :session_key => "_youApp_session_id", :secret => "some secret phrase of at least 30 characters" }

3. Heroku uses PostgreSQL as the underlying database. So do remember to setup database migrations before exporting your local app to Heroku. You can then export the migrations to Heroku. Heroku doesn't have an interface to run sql to create tables. Rightly so as beauty of Rails lies in abstraction of the underlying database from the application.

4. Do watch some of the screencasts of getting started with Heroku and using the other features.

Here are some screens of Heroku running my webapp.









Great! Hope you have a great time with Rails and Heroku. Happy Coding!
Post a Comment