Unobtrusive Ajax on Rails3: Welcome to rails-ajax

My recent contribution to Rails: rails-ajax.

Here is its story:

I am always amazed to see how simple the Ajax use-case can be, how many websites could take benefit from a basic Ajax setup, and yet how difficult it is to integrate a decent Ajax solution to existing websites.

Ajax is a set of techniques allowing asynchronous data exchanges between a web server and its client browsers. Most of the time, those data exchanges tend to refresh parts of web pages, without having to refresh the whole web page. Faster, saves bandwidth, smoother user experience… all benefits.
However with Ajax implementations on websites, many drawbacks have to be taken care of: browser’s URL don’t update, scripts aren’t executed, browser’s history does not work, browsers disabling JavaScript need special attention…

Lately I wanted to use Ajax on an existing Rails 3.2 website. Could not find any decent gem that was still maintained, used state-of-the-art libraries and worked with Rails > 2.

Therefore I decided to use some of the best libraries handling Ajax, HTML5, browsers’ history and no JavaScript fall-back solutions, and integrate them into a nice gem that would turn any Rails3 website into an ajaxified one. Welcome to rails-ajax !

It uses Rails’ UJS, History.js and jQuery to ajaxify websites without altering their application code.

It is unobtrusive, very simple to setup, handles browser’s history and bookmarking, takes care of scripts and redirections, is customizable to refresh several parts of web pages, works with all common browsers, falls back nicely when JavaScript is disabled.

You can check the complete documentation and examples on the rails-ajax web page directly.

Feel free to use it and contribute to it too !

About Muriel Salvan

I am a freelance project manager and polyglot developer, expert in Ruby and Rails. I created X-Aeon Solutions and rivierarb Ruby meetups. I also give trainings and conferences on technical topics. My core development principles: Plugins-oriented architectures, simple components, Open Source power, clever automation, constant technology watch, quality and optimized code. My experience includes big and small companies. I embrace agile methodologies and test driven development, without giving up on planning and risks containment methods as well. I love Open Source and became a big advocate.
New gem, Ruby on Rails , , , , , , , ,

Leave a Reply

Your email address will not be published.