Monday, July 14, 2008

Take your Rails application offline with the Gears on Rails project



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 http://gearsonrails.googlecode.com/svn/trunk/acts_as_local
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:
def create_local
'
post = Post.build(params("post"));
Post.create_local(post);
window.location.reload( false );
'
end
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).

7 comments:

  1. Hi, I'm the author of Jester. This is a totally awesome plugin, and a great usage of the Jester library. I'd like to use this in a Camping app, I might have to fork it or something to make it less Rails-specific.

    I'd love to send Michael and Rui an email or something, but I can't find their presence or contact info online. I'll risk posting my email up here publicly -- it's emill@thoughtbot.com, if they want to reach me about anything.

    Great work!

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. @Tom

    It looks like the SymmetricDS project has not been implemented with SQLite yet, which I believe is what Gears uses.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. Since so many times there is no update for this project, any problem? or what?

    ReplyDelete