Thursday, March 5th, 2009

Dojo + Rails = Drails?

Category: Dojo, Rails

Bob Remeika pointed us to his recent labor of love: Drails:

Introducing Dojo support for Ruby on Rails!

drails is a helper library for using Dojo alongside Rails. It provides a Dojo implementation for all of the Rails helpers that would normally generate Prototype/Scriptaculous code so now ajaxifying your Rails application with Dojo is as simple as using the built in support that Rails already provides for Ajax, effects, and drag-and-drop.

Along with this release, drails also includes support for the following:

– Generating Dojo Dijits (along with the appropriate test files)

– Generating modules (along with the appropriate test files)

– Generating a dojo build profile based on the scripts that currently reside in your application

– Rake tasks for creating a dojo build which can easily be added to a capistrano task for deployment

I wanted to say a big thank you to all that have helped, especially Jon Moeller and the Dojo Foundation, for providing great ideas and code during GSoC. The project has been a long time coming and I’m very happy to say that it’s finally at a point where it can be used.

The source and installation instructions are available on github:

Anyone using it yet?

Posted by Ben Galbraith at 6:00 am

3.6 rating from 28 votes


Comments feed TrackBack URI

It might be a “newbie” question but well… Why would you use Dojo instead of Prototype? I’m not very familiar with Dojo, in what way is it different/more interesting?

Comment by Flornet — March 5, 2009


It mostly comes down to a matter of style and taste. Also, Dojo has a lot more functionality out of the box for widgets and other advanced features that you would need to use additional libraries for if you weren’t using it. has lots of examples.

Comment by smith — March 5, 2009

Is there any live demo of an app using d-rails?

Comment by sos — March 5, 2009

@sos: I used to have one for the version previous to this so I can reuse some of that. I can probably have something up tomorrow or the next day.


Comment by foobarfighter — March 5, 2009

@Flornet: As smith said, it’s largely a matter of taste and style, but I’d also say that Prototype is barely comperable to Dojo in terms of depth… Prototype gives you the basics you’re likely to need, kind of extending JavaScript into what it should have been all along, but Dojo is a much richer, full-featured API for building webapps… it’s kind of like comparing the C standard library to Java’s class library… the C standard library is immensely useful, but it’s effectively a subset of what the Java class libraries offer (I realize it’s a little unfair comparing a library in one language to a library in another language, but the point is that you’re likely to find analogies to pretty much everything in the C standard library in the Java class libraries, and then a whole lot more on top of that).

Comment by fzammetti — March 5, 2009

@Flornet: Agree with the others about Dojo. I would also add that Rails and Dojo are a great fit if you look at how nicely Rails easily emits your object data as JSON. Add a few tweaks and you can very easily reformat that JSON to the format expected by reference implementations, ItemFileReadStore and ItemFileWriteStore. So with a few lines of ruby and two dojo tags you can have a data backed grid in no time. Also, the declarative nature of dojo, and it’s awesome parser, makes it simple to pass dojoType=… as part of the HTML_OPTIONS property on any of the existing helpers so you can easily dijit-ify your forms.

Comment by maddesa — March 5, 2009

Why doesn’t Rails just become JS library agnostic?

Comment by Tr0y — March 5, 2009

Tr0y: I think that’s actually going to happen with Rails 3. I remember reading about that somewhere..

Comment by Piinaaja — March 6, 2009

This is great! Although Prototype/Scriptaculous are helpful, it is the widgets that I really need.

I am new to Dojo, however, and quite sure on how Dojo and the Rails MVC model would interact. Is there a sample application that can be posted?

Comment by boosey — March 7, 2009

@boosey, @sos: I added an example application that can be used to demonstrate drails in action. It’s still a work in progress, but you can check it out on github.

Comment by foobarfighter — March 8, 2009

@foobarfighter: thanks!

Comment by GibsoundSG — June 30, 2009

Leave a comment

You must be logged in to post a comment.