views:

345

answers:

2

I have been tasked with exploring the possibility of offline access of my webapp. What are people's experiences using google gears with rails? I am aware of the gearsonrails project, but it has some really strange constructs and doesn't appear to be under significant, active development.

Are there other options? Has anyone added gears to their existing rails app successfully? Is this super-painful?

A: 

I am looking into this myself - generally the idea is that depending on what you want to make available offline you need to setup on the client side (note, this is untested, and hence unverified - I'm just going from my understanding of what I have read - although I am planning on doing some experimentation in the next few weeks...)

In most situations I would recommend setting up standard restful resources with Rails, and then in your client library do something like the following:

  1. When the page is loaded, determine if Gears has loaded, and if your database is available on the client.
  2. Create the database if necessary.
  3. Using the worker process, intialize a call into your RESTful controller to obtain the data you need - and on the return of the data write it into the local database (using the worker process will allow for a 'multi threaded' experience and make sure you dont lock up the client.
  4. Periodically poll the remote server checking for changes in the data - if needed pull down a fresh set and reload the local data cache.
  5. When the client is offline switch to using the local client database.

Obviously this is a read-only example, and relies on the existing architecture using AJAX client side calls to populate data in the page etc.

Your means might vary, but I recommend just having a play around - remember you don't have to use Rails plugins etc to do this - you can just roll the client side script by yourself - and you never know, once your done you might be able to refactor your work out into a great little gem or similar...

Matthew Savage
+1  A: 

Google Gears is dead, development has ceased. You're better off trying to solve your problem using HTML5, which implements APIs that make offline access possible (a client side database that can be queried using a SQL like language and a key-value store.) At this point, none of the major browsers completely implement the (developing) standard. So you have to make the decision between developing against a de facto obsolete plugin, or targeting an emerging standard.

Steve Graham
Yup. Honestly, there was part of me that was happy to see the news yesterday. However, now I just have to convince my company that something other than IE is what we need.
salt.racer
I suspect it might be easier to try an "under the radar" approach and get them to adopt the chrome frame plugin?
Steve Graham