# "Offline" rails app?

**URL:** <https://www.ruby-forum.com/t/offline-rails-app/60913>\
**Category:** Rails\
**Created:** [January 11, 2006, 6:54am UTC](https://www.ruby-forum.com/t/offline-rails-app/60913 "2006-01-11T06:54:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [January 11, 2006, 6:54am UTC](https://www.ruby-forum.com/t/offline-rails-app/60913/1 "2006-01-11T06:54:29Z")

</div>

Hope this question doesn’t sound too strange. This is a typical  
synchronization scenario, and I’ve done this a lot with .Net “rich  
clients”, but I’m fairly new to web programming and to rails.

I’m developing browser-based applications that will sometimes have to be  
disconnected from the internet. One example is a browser-based app for  
conference registrations. At the hotel, I’d like to provide laptops  
with my app hosted locally, since there may not be internet connections  
available. I would use MySQL on the client, etc. so that to the rails  
app, everything seems normal.

But when there is an internet connection, I would want to push to the  
“master” database any new rows that have been added to certain tables,  
and to pull down and updates that have been made to the master since  
that client last connected.

MySQL only seems to support one-way replication, from slave (the client)  
up to the master. So I’m thinking I need to write some code to perform  
the synchronization myself.

My questions are:

- is there any advice on a “canonical” way to switch the rails app from  
offline mode to online mode? Would SwitchTower be of any use here?
- can anyone confirm/deny my fears that MySQL can’t do this for me  
automatically?
- is there something really obvious that I’m missing here?

Thanks!  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [January 11, 2006, 9:22am UTC](https://www.ruby-forum.com/t/offline-rails-app/60913/2 "2006-01-11T09:22:14Z")

</div>

This could be done…

sqlite on the client…

deploy the app as an .exe (search for tutorial)…

add scheduled task on laptop so that it tries to sync with the master  
every hours/whatever…

could be done…

Mikkel

Jeff C. wrote:

> Hope this question doesn’t sound too strange. This is a typical  
> synchronization scenario, and I’ve done this a lot with .Net “rich  
> clients”, but I’m fairly new to web programming and to rails.
> 
> I’m developing browser-based applications that will sometimes have to be  
> disconnected from the internet. One example is a browser-based app for  
> conference registrations. At the hotel, I’d like to provide laptops  
> with my app hosted locally, since there may not be internet connections  
> available. I would use MySQL on the client, etc. so that to the rails  
> app, everything seems normal.
> 
> But when there is an internet connection, I would want to push to the  
> “master” database any new rows that have been added to certain tables,  
> and to pull down and updates that have been made to the master since  
> that client last connected.
> 
> MySQL only seems to support one-way replication, from slave (the client)  
> up to the master. So I’m thinking I need to write some code to perform  
> the synchronization myself.
> 
> My questions are:
> 
> - is there any advice on a “canonical” way to switch the rails app from  
> offline mode to online mode? Would SwitchTower be of any use here?
> - can anyone confirm/deny my fears that MySQL can’t do this for me  
> automatically?
> - is there something really obvious that I’m missing here?
> 
> Thanks!  
> Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [January 11, 2006, 10:01am UTC](https://www.ruby-forum.com/t/offline-rails-app/60913/3 "2006-01-11T10:01:18Z")

</div>

took the word right out of my mouth mikel, just one addition…

[http://www.erikveen.dds.nl/distributingrubyapplications/rails.html](http://www.erikveen.dds.nl/distributingrubyapplications/rails.html)

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [January 11, 2006, 11:23am UTC](https://www.ruby-forum.com/t/offline-rails-app/60913/4 "2006-01-11T11:23:52Z")

</div>

I have the same requirements … so am I right to assume that I can do a  
two-way replication/sync over the Internet using sqlite and mysql?

Or would the ‘synching’ bit have to be a manual implementation - using  
say webservices or something? This is the approach I was about to embark  
on.

Joerg

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [January 11, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/offline-rails-app/60913/5 "2006-01-11T14:13:25Z")

</div>

Jeff C. wrote:

> I’m developing browser-based applications that will sometimes have to be  
> disconnected from the internet. One example is a browser-based app for  
> conference registrations. At the hotel, I’d like to provide laptops  
> with my app hosted locally, since there may not be internet connections  
> available. I would use MySQL on the client, etc. so that to the rails  
> app, everything seems normal.

I vaguely remember seeing an entry about offline capabilities in a  
roadmap for firefox 2.0. But now I can’t find it anymore.  
I think it would be awesome if you could just open a web page from the  
browser cache and use it’s forms for entering data. The data is saved  
through a js interface to something like a cookie, that can be read by  
the page on the next HTTP connection to the page.  
On [http://wiki.mozilla.org/Firefox:2.0\_Product\_Planning](http://wiki.mozilla.org/Firefox:2.0_Product_Planning) there is a  
mention of “Supercookies”. Is it possible that this is something like  
what I described?
