Google Gears Takes Ruby on Rails Offline

The Gears on Rails project by Google Gears enables Ruby on Rails developers to take their applications offline, as some sharp developers put Gears to new and different uses.

Developers are putting Google Gears to some interesting uses, including offline support for Ruby on Rails and building client-side search engines.

Gears for Rails represents another boost to cloud computing in its ability to deliver offline capability and synchronization. Meanwhile, Microsoft is leading its own data synchronization charge with its Live Mesh cloud-based data synchronization system, a test build of which is now open to the public.

However, Google has pushed its way into the cloud-based development world. And the third-party Gears for Rails solution also represents another call for Google to open up its Google App Engine platform to other languages, such as Ruby. Currently, the Google App Engine development platform supports Python only.

Michael Marcus and Rui Ma, two recent graduates from the information systems masters program at New York University, have designed a development framework called Gears on Rails. Google Gears is an open-source browser extension that lets developers create Web applications that can run offline. Gears on Rails is an open-source project that plugs Google Gears into Ruby on Rails, enabling developers to take a Ruby on Rails code base offline.

In a blog post about the project, Dion Almaer, a Google engineer, said, "Gears on Rails helps developers to write fully offline functional Web applications based on Gears without learning a bit of Gears ... The sweet spot is building a Rails application that can handle local interactions without having to drop down to Gears JavaScript APIs themselves."

Almaer also did an interview with Marcus and Ma in which Ma described Gears on Rails as a proof-of-concept project whose goal is "to let developers build the offline version of their Web site without having to know anything about Gears or even to learn new techniques."

To enable this, the duo did two key things, said Marcus in the podcast of the Gears on Rails team's interview. "We tried to do as much native Rails code as possible to frame the JavaScript portion of Gears," he said. "And on the JavaScript side we've created an API that looks syntactically a lot like Ruby, so that the JavaScript that developers do need to write is very comfortable for them and something they can learn very easily."

Developers using Gears on Rails need not worry about the data synchronization between the server and the clients or about database schema updates, Ma said. "Because our framework takes care of underlying technologies like database synchronization and the generation of Google Gears manifest file ... developers only need to write Ruby-like JavaScript and they follow the same development experience as if they were using Ruby on Rails," Ma said.

The team built a mechanism that detects the current status of the environment-whether online or offline-"so our framework can switch from the online to the offline version," Ma said.

Gears on Rails takes advantage of the REST (Representation State Transfer) capabilities of Rails "without building any additional pieces on the server side to actually do the synchronization," Marcus said.

"What we're asking developers to do is write local versions of their controllers and views..." he said. "So you're basically doing the exact same thing in JavaScript on the local side that you're doing in Ruby on the server side."

Marcus also said Gears on Rails makes use of a framework called Jester that "allows you to do RESTful calls through JavaScript. That's what we built on, the notion that you can create, edit and destroy records on a database through JavaScript."