Agile Ajax

jRails: Ruby on Rails with the Prototype guts ripped out

My esteemed colleague Noel Rappin sensibly advocates doing things the Rails way whenever possible. As a Rails noob, I should follow his advice. But as a dedicated user interface developer, I'm already finding that many of the best practices of my discipline take extra steps to enforce in Rails. Case in point: The ability to write unobtrusive JavaScript using my tool of choice, jQuery.

I'm finally getting the chance to work on a real-life Ajax/Rails project, but I was leery about returning to the framework's built-in Prototype.js library after a year working almost exclusively with jQuery. I was worried that my Prototype skills had grown rusty - and that I'd miss all of the little tricks I've learned in jQuery. Besides, I had nightmares about Prototype's bind method forcing itself upon me brutishly.

Luckily, I discovered jRails, which replaces the Prototype parts of Rails with a custom fork of jQuery, jQuery FX and jQuery UI. With jRails installed, all of the familiar Rails helpers function as usual: form_remote_for, observe_form and link_to_remote. But under the hood, they're running on jQuery instead of Prototype, which makes it much easier to integrate your custom, client-side jQuery-style JavaScript with the auto-generated stuff Rails spits out.

You could just as easily yank Prototype out of your Rails app manually, then replace it with jQuery and any plugins that you need. I may do just that, since the version of jQuery UI that's included with jRails is somewhat out of date. Still, it's cool to be able to tell a skittish Rails pro that my JavaScript toolkit switcheroo won't break any of the Rails helpers he's used to.

Comments: 2 so far

  1. I can’t wait until Rails is JS-Lib agnostic… I sure do miss my mootools.

    Comment by Andrew Herron, Wednesday, June 11, 2008 @ 3:30 pm

  2. +1 for Javascript library agnosticity (is that a word?)

    Comment by Jamie Hill, Sunday, June 15, 2008 @ 12:04 pm

Leave a comment

Powered by WP Hashcash

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com