Jeb Wilkins

Coding and climbing in Cumbria.

Rails and RJS

We’ve just started a ‘big new’ project in work and we’ve decided to develop it using Rails. I’ve done various odds and sods in Rails before but I learnt from version 1 of the Agile Web Development book, hence only know stuff as far as Rails 1.0 so I’ve spent the last couple of days getting up to speed on Rails 1.1 and 1.2 technologies. So far I’ve been impressed, coming from a PHP and MySQL background Migrations are a dream, from within TextMate I can update the schema and roll the database forward all without leaving my editor, on the couple of occasions I’ve needed to do corrections to migrations I’ve been able to easily roll down a couple of migrations, correct the migration then roll back forwards. I’m not sure if your really meant to modify migrations ‘after the fact’ but this seems to work well enough for me.

The other thing thats really impressed me is RJS - currently I’m creating various ajax’y admin interfaces and its been a god send. I can just write views for various actions in the controller which instead of generating content, modify multiple parts of the clients existing page - all with 3 or 4 lines of ruby. This then keeps the ‘view’ part separate from the controller, eg adding a new usergroup can be done in the controller, but I’ve still got my changes to the clients view in a separate file - normally this would end up as a mess of partials, serialised together, and a bit of js already on the client to untangle the partials and put them in the right locations.