Offline rails application

98 views
Skip to first unread message

amitoj singh

unread,
Jul 27, 2016, 8:04:57 AM7/27/16
to rubyonra...@googlegroups.com, li...@ruby-forum.com
Hello Developers,
I am working on a Web rails project which is working fine with the
Internet. But I have to use this project in the areas where there is
no or very less internet connection. So I would have to make this web
application work offline.

The application contains multiple pages. How can I do so? I thought to
do so using cache I have found this
http://guides.rubyonrails.org/caching_with_rails.html. Can I use this
in my application? If yes then how?. I want all my views(html) as well
as assets( stylesheet and Javascript) should work offline.

I had tried rack offline but it can only do single page offline. Now I
am working on service worker but still unable to do multiple pages
offline.
Thanks.


--
"Never repeat yourself"
Amitoj singh
slideshare.com/amitoj95
github.com/amitojsingh
amitojsworld.wordpress.com

amitoj singh

unread,
Jul 27, 2016, 11:53:38 AM7/27/16
to rubyonra...@googlegroups.com, li...@ruby-forum.com
On Wed, Jul 27, 2016 at 5:25 PM, amitoj singh <amitoj...@gmail.com> wrote:
> http://guides.rubyonrails.org/caching_with_rails.html. Can I use this
> in my application? If yes then how?. I want all my views(html) as well
> as assets( stylesheet and Javascript) should work offline.


I had use this It works for a few minutes but after that it won't why so?

Colin Law

unread,
Jul 27, 2016, 12:05:35 PM7/27/16
to Ruby on Rails: Talk
On 27 July 2016 at 12:55, amitoj singh <amitoj...@gmail.com> wrote:
> Hello Developers,
> I am working on a Web rails project which is working fine with the
> Internet. But I have to use this project in the areas where there is
> no or very less internet connection. So I would have to make this web
> application work offline.
>
> The application contains multiple pages. How can I do so? I thought to
> do so using cache I have found this
> http://guides.rubyonrails.org/caching_with_rails.html. Can I use this
> in my application? If yes then how?. I want all my views(html) as well
> as assets( stylesheet and Javascript) should work offline.
>
> I had tried rack offline but it can only do single page offline. Now I
> am working on service worker but still unable to do multiple pages
> offline.

Rails caching as described in the guide describes how to cache common
pages on the server, not in the browser PC. If you do not have access
to the internet (and therefore cannot access the server) then this
form of caching will not help.

If you want to use your application offline then the pages must be
saved somewhere. Where are you hoping that this might happen? In
the browser?

Colin

> Thanks.
>
>
> --
> "Never repeat yourself"
> Amitoj singh
> slideshare.com/amitoj95
> github.com/amitojsingh
> amitojsworld.wordpress.com
>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAKiq3e%3DkGm_GVcZRxDwMVANWX5XdU-mAOVD%3DSP%3DnAzYo4d01zw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

amitoj singh

unread,
Jul 27, 2016, 12:29:08 PM7/27/16
to rubyonra...@googlegroups.com
On Wed, Jul 27, 2016 at 9:34 PM, Colin Law <cla...@gmail.com> wrote:
>
> Rails caching as described in the guide describes how to cache common
> pages on the server, not in the browser PC. If you do not have access
> to the internet (and therefore cannot access the server) then this
> form of caching will not help.
>
> If you want to use your application offline then the pages must be
> saved somewhere. Where are you hoping that this might happen? In
> the browser?
>
> Colin

Yup. Actually, I thought to do this by using browser cache. Is this
the right way to do so? Is there any other way to do this?

Rupinder Kaur

unread,
Jul 28, 2016, 9:04:39 AM7/28/16
to Ruby on Rails: Talk


On Wednesday, July 27, 2016 at 9:35:35 PM UTC+5:30, Colin Law wrote:
On 27 July 2016 at 12:55, amitoj singh <amitoj...@gmail.com> wrote:
> Hello Developers,
> I am working on a Web rails project which is working fine with the
> Internet. But I have to use this project in the areas where there is
> no or very less internet connection. So I would have to make this web
> application work offline.
>
> The application contains multiple pages. How can I do so? I thought to
> do so using cache I have found this
> http://guides.rubyonrails.org/caching_with_rails.html. Can I use this
> in my application? If yes then how?. I want all my views(html) as well
> as assets( stylesheet and Javascript) should work offline.
>
> I had tried rack offline but it can only do single page offline. Now I
> am working on service worker but still unable to do multiple pages
> offline.

Rails caching as described in the guide describes how to cache common
pages on the server, not in the browser PC.  If you do not have access
to the internet (and therefore cannot access the server) then this
form of caching will not help.

If you want to use your application offline then the pages must be
saved somewhere.  Where are you hoping that this might happen?   In
the browser?

Colin

Hello developers,

I am also facing the same problem. I am trying to make the whole rails app offline which has multiple pages with dynamic content and photos as well as the audio file. I tried the rack-offline but found that it does not work for me because it is outdated and then try the serviceworker-rails gem and follow the  https://rossta.net/blog/offline-page-for-your-rails-application.html tutorial and create one page that works offline when the app is not connected to the internet but my requirement is to make the multiple pages of the application work offline which have dynamic content instead of creating a new page. Please suggest me some alternative. I am new in rails and I tried a lot of ways but did not get the solution yet because I don't have any prior experience. How should I store the pages that will work offline? How can we do so? 
Thanks :).

Colin Law

unread,
Jul 28, 2016, 9:09:35 AM7/28/16
to Ruby on Rails: Talk
What do you mean by "dynamic content"?

Colin

Rupinder Kaur

unread,
Jul 28, 2016, 10:23:54 AM7/28/16
to Ruby on Rails: Talk
What do you mean by "dynamic content"?

Colin
Dynamic content means that the data is fetched from the database ( PostgreSQL database). For an example, we have a web page like to show the list of the members. The list is shown from the database and we can add or remove the members even when we are offline and when we connect to the internet it sync the data.

Colin Law

unread,
Jul 28, 2016, 10:41:07 AM7/28/16
to Ruby on Rails: Talk
I do not know how you could do that other than by writing an
application that you install on the PC or on the local network.

Colin

Rupinder Kaur

unread,
Jul 28, 2016, 10:47:07 AM7/28/16
to Ruby on Rails: Talk

I do not know how you could do that other than by writing an
application that you install on the PC or on the local network.

Colin

Sorry, did not get you :(. 

Colin Law

unread,
Jul 28, 2016, 11:00:00 AM7/28/16
to Ruby on Rails: Talk
I mean that I cannot see how you can get the browser to do the things
you describe while it is not connected to the internet. The only way
I can see to do it is to have an application running on the PC or on
another machine on your local network that does those things.

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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/a02b5e67-139c-4035-ba4b-0befeb844b71%40googlegroups.com.

tamouse pontiki

unread,
Jul 29, 2016, 12:02:45 AM7/29/16
to rubyonra...@googlegroups.com
It sounds to me as though you both (amitoj singh and Rupinder Kaur) actually want to run from a server that is not attached to the internet, but you can still point your browsers at. This retians the rails-ness of your application, but doesn't allow anyone on the internet to access it.

Mike

unread,
Jul 29, 2016, 4:58:32 AM7/29/16
to Ruby on Rails: Talk
Reading the original post it sounds like the application is on the internet, but if the user is in a bad signal, or middle of the jungle area with no signal they still want the app to work. 

There is no way that this will really happen as the dynamic pages will still require a connection to the server, you cannot cache a dynamic page (you can cache the result of a call for a limited time, but that is not dynamic), that is the point, it is dynamic, and so needs connectivity. you can cache the static assets, but that is about all.

amitoj singh

unread,
Jul 29, 2016, 6:48:34 AM7/29/16
to rubyonra...@googlegroups.com
On Fri, Jul 29, 2016 at 2:28 PM, Mike <mike.s...@gmail.com> wrote:
> Reading the original post it sounds like the application is on the internet,
> but if the user is in a bad signal, or middle of the jungle area with no
> signal they still want the app to work.

Yup, The application is specially design for them who can not assess
the internet or the internet is not available there.

> There is no way that this will really happen as the dynamic pages will still
> require a connection to the server, you cannot cache a dynamic page (you can
> cache the result of a call for a limited time, but that is not dynamic),
> that is the point, it is dynamic, and so needs connectivity. you can cache
> the static assets, but that is about all.

The main thing in our application which we want to store in the cache
is a form. User can view and enter their information in the
form(without internet connectivity) and that information is stored
locally and when the application connects to the internet can
automatically sync the data which is present locally with the main
database on the server.

Mike

unread,
Jul 29, 2016, 7:49:35 AM7/29/16
to Ruby on Rails: Talk
I doubt you can do that, you would need to have a local copy of the rails app running against a local database I would have thought, but that is probably not good for security

Hassan Schroeder

unread,
Jul 29, 2016, 9:06:21 AM7/29/16
to rubyonrails-talk
On Fri, Jul 29, 2016 at 3:47 AM, amitoj singh <amitoj...@gmail.com> wrote:

> The main thing in our application which we want to store in the cache
> is a form. User can view and enter their information in the
> form(without internet connectivity) and that information is stored
> locally and when the application connects to the internet can
> automatically sync the data which is present locally with the main
> database on the server.

For that specific use case, you can write a browser-based JavaScript
application using local storage* but this really has little to do with Rails,
other than duplicating a lot of the logic of your app :-)

[*] https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Consulting Availability : Silicon Valley or remote

James Davis, PhD

unread,
Jul 30, 2016, 8:52:06 AM7/30/16
to Ruby on Rails: Talk
Perhaps a mobile app would provide the solution you seek. I recently created an iOS app (using RubyMotion) that works offline and syncs with my webapp when it has connectivity again.

Rupinder Kaur

unread,
Jul 31, 2016, 3:42:48 AM7/31/16
to Ruby on Rails: Talk

On Saturday, July 30, 2016 at 6:22:06 PM UTC+5:30, James Davis, PhD wrote:
Perhaps a mobile app would provide the solution you seek. I recently created an iOS app (using RubyMotion) that works offline and syncs with my webapp when it has connectivity again.
 
You means to create a new mobile app?

Neo Elit

unread,
Jul 31, 2016, 5:03:04 AM7/31/16
to Ruby on Rails: Talk, li...@ruby-forum.com
I think you could look at patterns of a progressive web application.
https://medium.com/@AdityaPunjani/building-flipkart-lite-a-progressive-web-app-2c211e641883#.4zqhjwuvx
flipkart mobile web application makes use of this. That's a life changing pattern for web apps but I'm afraid about compatibility issues with every browsers out there.
Reply all
Reply to author
Forward
0 new messages