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.
Topics: Javascript, jQuery, Progressive Enhancement, Prototype, rails, ruby
Comments: 2 so far
Leave a comment
About Pathfinder
Follow the Blog
-
Get a monthly update on best practices for delivering successful software.
Subscribe via email
Subscribe via RSS
Categories
Topics
Archives
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
Blogroll
Recent
- Elements of Testing Style
- Aesthetics and Web Design
- Asterisk-Java Testing with Groovy
- 3 Misuses of Code Comments
- Fluently NHibernate
- Digging a Hole and Covering it with Leaves — The Software Development Version
- The Importance of User Experience - Do You Understand It in Your Bones?
- Writing Your Own Protocol With NSURLProtocol
- What’s In Your Dock: iPhone edition
- Feature Fatigue

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
+1 for Javascript library agnosticity (is that a word?)
Comment by Jamie Hill, Sunday, June 15, 2008 @ 12:04 pm