Ajax Head Pattern; Unobtrusive Rails Apps

Written by on August 21st, 2008 in Uncategorized.

Ken Collins has rewritten his Homemarks application, a Rails app that “allows you to dynamically create and sort Columns, Boxes, and Bookmarks into your own custom start page.”

What is interesting about the rewrite is the new approach that Ken took; the Ajax Head Pattern as he described it:

HomeMarks was built using the Ruby on Rails framework with a heavy emphasis on object oriented JavaScript to make AJAX requests to a RESTful back-end. Unlike most Rails applications it does not use any inline JavaScript helpers nor does it rely on RJS (Remote JavaScript) for dynamic page updates. Instead it is nearly 100% unobtrusive JavaScript which uses simple HEAD or JSON responses to communicate to the objects on the page. This has yielded very slim controller code which is decoupled from the views and easily testable in isolation at a functional level.

You end up with a lot of code that deals with HEAD:

RUBY:

    class UsersController <ApplicationController
      # …
      def create
        User.create!(params[:user])
        head :ok
      end
      # …
    end

Source: Ajaxian » Front Page
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/370954772/ajax-head-pattern-unobtrusive-rails-apps

Comments are closed.



Site Navigation