Offline rails application

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.

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

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

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?

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 :).

What do you mean by "dynamic content"?

Colin

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.

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

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 :(.

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 :(.

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

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.

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.

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.

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

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 :slight_smile:

[*] https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API

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?

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.