Tuesday, April 25, 2006

Joining the Rails fashion set

Last weekend Simon and Stuart The Blogless and I joined the fashion set by putting our first Rails application into production. It's a real estate web site for a beautiful part of Australia called the Southern Highlands (about an hour from Sydney). You can visit Campbell Jones Property for a look if you like.

A few features of the site:
* the constrained box design was chosen by the client so don't blame me!
* funky interactive map on the search page - go Stuart!
* little ajaxy forms to submit feedback without doing page refreshes
* main image on the property listing page changes as you hover over the thumbnails
* client-side scrolling of bio information on the meet the team page

A few 'behind the scenes' things:
* all the images are in a Postgres database but are cached by Rails as they are used
* images are uploaded in hi-res by the client and crunched on the server using ImageMagick to generate the various form factors required for the site - a real time saver for the client
* lots of admin screens for updating listings, team members, etc

A few lessons learned as a J2EE guy working on his first Rails app:
* Rails makes the backend stuff so easy that the pain in the butt becomes all about the HTML and CSS - by far the most painful part on such a pixel-perfect design like this. Normally on a J2EE app you don't notice because everything is that painful!
* Postgres rocks
* Rails caching is very cool. The site warms up nicely
* database migrations are good but you can't sustain writing them using model objects if your model is changing (which it will). So you're basically writing SQL for migrations, but that's ok
* some of the Rails association stuff is a bit weird, but the worst thing is some of the 'silent failures' you get when saving related records. Never a good idea.
* some of the Rails plugins are a bit naive. For example, acts_as_list, which lets a model include positional ordering, doesn't let you put a UNIQUE constraint in the database for the position column as the update code is not transactional. Hope to find some time to fix that one.
* Rails routes rock

So what's the conclusion about Rails? Is it perfect? Hell, no! Is it productive? Hell, yes! Does it beat the J2EE stack for database-backed web apps? By a country mile. I will not choose J2EE over Rails to build such an application, that's for sure. To be honest, it feels a little like the Mac/Windows discussions I find myself having reasonably regularly. To say something is way better than something else does not mean the thing is perfect. It just means it's better. Rails is like that - it's not perfect, it's just way better. I sincerely hope that Rails does not go mainstream or we'll all have to go find something else to be our competitive advantage. May the industry behemoths ignore Rails for many years to come!

No comments:

Post a Comment