- We design and build extraordinary applications for companies looking to make the next great idea a reality.
- learn more
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
Recent
- iPhone SDK: UIViewController Testing & TDD
- Icons are evil; so are menus - unless you do them right
- The Truth About Designing For Security
- GWT, Gadgets and OpenSocial, Part 2
- Has Many has_many: A Refactoring Story
- The Hidden Power of Canvas
- Review of fixture_replacement2 plugin
- Chess Game Viewer in GWT
- From JSP to Ruby on Rails: First thoughts on front-end coding conventions
- Helpers and Partials
Archives
- 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


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