Forum: Ruby on Rails Synching between Sqlite and MySql

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-01-12 16:59
Hi folks,

I am running an offline Rails app that periodically connects to the
Internet to download the latest catalogue, and upload any new orders.

I am about to implement the synching bit - and was thinking whether
there is any other solution other than writing webservices and code to
do a manual sync of the data, or whether there is a more nifty and
robust way using say replication?

Anybody done anything like this before?

Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-01-12 17:36
(Received via mailing list)
Well, if the structure permist why not just use ActiveRecord to handle
all of that? Just change the model's database connetion. Assuming the
models are the same between offline and online clients this shouldn't
that difficult.

Check out the ActiveRecord rdocs for an example of having a model use
a different database. The wiki has a few entries concerning the topic

You of course would have to setup the syncing routine and all that
good stuff, but you would have to do that anyways  :)

34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-01-12 18:18
Not sure that this'll work, as the client is on a separate computer in a
different country ... it won't be possible for me to setup an SSH
connection for them to allow their app to speak directly to the remote
db ... the app is distributed on CD to various people who want it ...
616226cee3466e91febcd38f75c69194?d=identicon&s=25 Helmut Sedding (Guest)
on 2006-01-12 19:11
(Received via mailing list)

You could do that with a webservice, also written in Rails. You do not
need to expose a mysql-server this way. The CD-Application connects to
the webservice which intelligently transmits only the missing data to
the client. The action simply selects the data-rows where updated_at >


Am 12.01.2006 um 18:18 schrieb Joerg Diekmann:
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-01-12 19:32
Yeah - that's what I started doing - was just checking if there was an
easier solution ... especially synching up all the primary keys from all
the different CD's creating their own orders etc .... :-( Yikes.
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-01-12 20:26
(Received via mailing list)
On Jan 12, 2006, at 8:35 AM, Nick Stuart wrote:

> good stuff, but you would have to do that anyways  :)
> -Nick

	Be very careful if you decide to go this route. you cannot currently
obfuscate ruby code so your main server's database password will be
available to anyone you give the application to.

-Ezra Zygmuntowicz
Yakima Herald-Republic
Ce60c4f78a63b0695e4dafc4bd7964f7?d=identicon&s=25 Lou Vanek (Guest)
on 2006-01-14 11:22
(Received via mailing list)
Since Rails uses integer IDs instead of GUIDs, how are you going to
keep the IDs from colliding? (I'm assuming there's more than 1 user.)

Here are a couple of links that explain synchronization/replication,
but they are meant to be used by sysadmins:
Using MySQL's Built-In Replication To Maximize Availability
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-01-14 12:47
GUIDs would have to be the way to go. The only drawback I see of using
GUIDs is that the URL's become very ugly.

To use GUIDs you'd have to make your id column a 32 character string,
and instead of allowing ActiveRecord to use the DB to generate the
autoincrement id's, you set the id GUID value yourself in your model
before saving.

I haven't yet implemented it - just deducing that these could be the
steps to make Rails use GUIDs instead of int.

You could use to generate your

Any thoughts?
Ce60c4f78a63b0695e4dafc4bd7964f7?d=identicon&s=25 Lou Vanek (Guest)
on 2006-01-14 14:38
(Received via mailing list)
Yes, nasty ugly URLs.
I'm afraid I don't have any experience with GUIDs since IDs have been
sufficient for my needs. I was just interested in whether you had some
new, super-cool way of merging. You might also check out,
and Typo also uses GUIDs in a few places.
Lots of luck.
This topic is locked and can not be replied to.