Best way to data sync between Rails app and phone

269 views
Skip to first unread message

siva subrahmanyam

unread,
Jul 22, 2017, 2:20:15 AM7/22/17
to Ruby on Rails: Talk
Hi, 
I want build an Rails API which serves as backend for a mobile app. Since the mobile app will be used in offline mode. Hence I want data updates needs to be synced between mobile and web app. What would be the best possible solution for this kind problems?  

Hassan Schroeder

unread,
Jul 22, 2017, 10:28:25 AM7/22/17
to rubyonrails-talk
The one that meets your requirements, which you haven't defined.

* Where is the data changing that needs to be "synced"?

* Is the synced data on the phone unique to that user or shared?

* How frequently does it change and how big are the changes?

* How critical is it if the phone goes offline with data that's 5 seconds
old? 5 minutes? An hour?

etc. etc.

Draw a diagram of your application data flow and work from there.

HTH!
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

siva subrahmanyam

unread,
Jul 22, 2017, 11:30:35 AM7/22/17
to Ruby on Rails: Talk

Data will get updated on both sides ie., admin update data on web which needs to be synced with mobile and vice versa. Most of the users use mobile application offline mode as there is no network connectivity. Once the work done for entire day, they will be online and starts sync the data with server. Then we needs to sync recent updates. The data is unique for that user and remaining the users wont update the data apart from admin. 

Hope this helps. Let me know if you need more info. 

Hassan Schroeder

unread,
Jul 22, 2017, 1:14:21 PM7/22/17
to rubyonrails-talk
On Sat, Jul 22, 2017 at 8:30 AM, siva subrahmanyam
<subbu98...@gmail.com> wrote:
>
> Data will get updated on both sides ie., admin update data on web which
> needs to be synced with mobile and vice versa. Most of the users use mobile
> application offline mode as there is no network connectivity. Once the work
> done for entire day, they will be online and starts sync the data with
> server. Then we needs to sync recent updates. The data is unique for that
> user and remaining the users wont update the data apart from admin.
>
> Hope this helps. Let me know if you need more info.

So once a day when the user comes back online she or he opens
the app and it connects to the backend, sends its data and fetches
any updates. Sounds pretty straightforward.

What specific question do you have about this?

siva subrahmanyam

unread,
Jul 23, 2017, 10:42:08 AM7/23/17
to Ruby on Rails: Talk

My question is there any gem available or do we need to use any service to make sync successful ? 

Hassan Schroeder

unread,
Jul 23, 2017, 12:44:48 PM7/23/17
to rubyonrails-talk
On Sun, Jul 23, 2017 at 7:42 AM, siva subrahmanyam
<subbu98...@gmail.com> wrote:
>
> My question is there any gem available or do we need to use any service to
> make sync successful ?

Your client is sending requests to your web app. Other than Rails
itself (and the DB behind it) what do you imagine that you need?

siva subrahmanyam

unread,
Jul 24, 2017, 1:58:41 AM7/24/17
to rubyonra...@googlegroups.com
Thanks for your reply. I felt that we need a separate server to stream. If it can be done just with Rails & DB then I am fine. 

--
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/ie89tMc0HK0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDjbt0VNaGLwA4qz8ahwgN6wAYy6U3io9xWgBc5JL84Ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--

With Regards
  Ur's Subbu

Colin Law

unread,
Jul 25, 2017, 2:03:06 AM7/25/17
to Ruby on Rails: Talk
I achieve this by writing to an sqlite db in the android app and posting the records to the rails app when online.

Colin


You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.

To post to this group, send email to rubyonrails-talk@googlegroups.com.

John Ivanoff

unread,
Jul 25, 2017, 2:21:10 PM7/25/17
to Ruby on Rails: Talk
There's also a book on that.
Build iOS Database Apps with Swift and SQLite => http://www.apress.com/us/book/9781484222317

John


On Tuesday, July 25, 2017 at 1:03:06 AM UTC-5, Colin Law wrote:
I achieve this by writing to an sqlite db in the android app and posting the records to the rails app when online.

Colin

On 24 Jul 2017 6:58 a.m., "siva subrahmanyam" <subbu98...@gmail.com> wrote:
Thanks for your reply. I felt that we need a separate server to stream. If it can be done just with Rails & DB then I am fine. 
On Sun, Jul 23, 2017 at 10:14 PM, Hassan Schroeder <hassan.s...@gmail.com> wrote:
On Sun, Jul 23, 2017 at 7:42 AM, siva subrahmanyam
<subbu98...@gmail.com> wrote:
>
> My question is there any gem available or do we need to use any service to
> make sync successful ?

Your client is sending requests to your web app. Other than Rails
itself (and the DB behind it) what do you imagine that you need?

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/ie89tMc0HK0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.



--

With Regards
  Ur's Subbu

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

Antônio Augusto Sousa Britto

unread,
Aug 4, 2017, 5:08:16 PM8/4/17
to rubyonra...@googlegroups.com
You should take a look at Firebase. It does a great job on sync at mobile apps and the cloud database. Then you'll need only to create a service to sync web database to cloud database, if needed.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9826c9aa-01ed-42e8-8662-757f4e420a17%40googlegroups.com.

Heather Orr

unread,
Sep 1, 2017, 2:37:46 AM9/1/17
to Ruby on Rails: Talk
Hi,

In addition to the book mentioned in this thread, this site with RailsGuides is super helpful too: http://edgeguides.rubyonrails.org/api_app.html  

Brendon

unread,
Sep 1, 2017, 1:14:13 PM9/1/17
to Ruby on Rails: Talk


On Friday, July 21, 2017 at 11:20:15 PM UTC-7, siva subrahmanyam wrote:
Hi, 
I want build an Rails API which serves as backend for a mobile app. Since the mobile app will be used in offline mode. Hence I want data updates needs to be synced between mobile and web app. What would be the best possible solution for this kind problems?  

The trickiest part of this type of architecture is handling problems like multiple updates to the same object from different sources. Since it sounds like you are not going to have much of that -- but it does need to be handled in some way if it can happen at all!

Google's Protobuf stuff is pretty good for packaging data in a cross language portable way and is much faster than JSON in RoR. But if your volume of data and connections is reasonable, then JSON is pretty easy to deal with in Ruby, Java and I assume Swift.

Using simple object APIs in RoR is what we have done in the past. If you don't use some external service, you usually end up creating a simple protocol for the phones to use to communicate with the back end.

Communications from the server to the phone can be done in an easy way by having the mobile device periodically check for updates, at which time the server can tell it what messages it needs. The more complicated way is to use the platform notification system (On Android it is Google Cloud Messaging) to tell the device to check-in with the server. The important point is that these push notification systems don't typically guarantee delivery. Google for example says it may deliver 1 message even if you send 10. So that means you really only want to use it to poke the app into checking in with the server.

Regards,
Brendon.
 
Reply all
Reply to author
Forward
0 new messages