Take your Rails application offline with the Gears on Rails project

JUL 14, 2008
By Dion Almaer, Google Developer Programs

Using iTunes?
Michael Marcus and Rui Ma, two recent graduates from a masters program at NYU, join us to discuss Gears on Rails, their open source framework that makes it easier than ever to take a Rails code-base offline.

We start out discussing the genesis of the project and what it is trying to do. The sweet spot is building a Rails application that can handle local interactions without having to drop down to Gears JavaScript APIs themselves.

First you install the Gears on Rails plugin via:
ruby script /plugin install
Then you can create a Rails controller and tell it that it is local via acts_as_local :except=>['hello'].

Now you can create an action in the controller by creating a method that uses an API that looks Rails-like:
post = Post.build(params("post"));
window.location.reload( false );
In that string, the framework is actually building on Jester, a "JavaScript client for REST APIs that uses Rails conventions". Rui explained how they built out the local versions of the calls.

This means that your architecture revolves around REST calls, and when you are offline they all occur on local data that can sync up later. The synchronization is done for you automatically.

Thanks to Michael and Rui for taking the time to discuss their project with us, and thank you for reading.

Listen to the audio interview directly (or subscribe via iTunes).