Monday, September 14, 2009

My first Rails App!

After a few days of pouring my mind over Ruby and Rails, I have finally completed my very first web application in an afternoon. It is called Podcast Lookup which aggregates the podcasts I listen to on a regular basis. The web application simply shows the publish date of the latest episodes. It is quite useful if you listen to a large number of podcasts and need a way to view them all when jumping across different OS. The project still needs a lot of improvements which I can iterate on from now on, isn't that what the whole agile development hotness is these days?

Some thoughts on Rails

Functionality drop out of the sky into your lap. This is mostly how the Rails framework is implemented, it tries to make the developer life easy and lazy by achieving a lot with the least amount of code and without having to know where methods or variables come from. Not that it's a bad thing for someone coming from C++, Java or Python but I'll be very worried on how someone who only knows Ruby and Rails can move outside their comfort zone.

Ruby on Rails will hold both your hands and spoon feed you to make your life as a Web Developer easy and productive. In some ways, it feels like Perl because I am not sure what some of the minimal code is trying to do. Having a reference manual nearby seems invaluable. Maybe it's too early for me to judge the framework after only playing with it over the last 3 weeks. I'll be working on it a bit more over the next few months to get a better feel of it.

Rails for newbies

If you want to learn Ruby on Rails, DO NOT DEVELOP ON WINDOWS. Do yourself a favour and save some time by writing codes on Linux or Mac. You will avoid a lot of Yak shaving that way. Ruby 1.9.1 and Rails 2.3.3 simply do not play well with Windows when you go beyond the out of the box features. Some gems will just refuse to install on Windows unless you do some configure and build gymnastics on them. You are here to learn the language and framework, not building source code unless that is your motivation, I have done enough of that for the last 4 years.

The Rails Guide is a stepping stone to get yourself familiar with the technology. Once you have exhausted this resource, borrow Simply Rails 2 from your local library if it is available and do the example project. It will really help you develop your pet project if you have one. Other necessary tools:
  • Optional - Balsamiq Mockup for fast prototyping on how your web app will look like.
  • Github for SCM and to show off your source code. It is free for public repositories. Git is also the revision control of choice if you want to become a Ruby on Rails acolyte.
  • Heroku provides free Ruby on Rails web hosting. Their web site doesn't say it explicitly but you can host multiple small Rails web app over there. However, your application won't be able to write to disk when hosted on their server, at least for the free plan. This may or may not be an issue depending on the nature of your project.

    Advanced developer: Pushing data from your local machine to the Heroku server can be tricky because the schema_migrations table has already been created and populated by the time you call:
    rake db:push
    The stupid way to handle this at the moment is to quickly prefix your local schema_migrations with z to become zschema_migrations and invoke the above command. It will fail when it reaches zschema_migrations turn but data from other tables will be uploaded.
This is my opinion on Ruby and Rails and I think developers who are interested of the current buzzword should consider giving it a try. Even if you don't like the Ruby language or Rails framework, you might learn some new approach from the experience. It's the journey that makes it exciting, not the end goal.

No comments: