Adding Native HTML5 Support to a Rails 3.1 Application

I want to add standalone HTML5 support for my Rails 3.1 application, and I came across rack-offline , a gem suitable for this purpose. However, the rack only adds assets to the public folder in the application cache manifest file. How can I add all compiled assets from my assets folder (those generated by the asset pipeline)?


In particular, my routes.rb has the following:

 offline = Rack::Offline.configure do cache "images/masthead.png" public_path = Rails.public_path Dir[public_path.join("javascripts/*.js")].each do |file| cache file.relative_path_from(public_path) end network "/" end 

Just like I have Rails.public_path , can I get the path to compiled assets? That way, I can use the code above to add files to this path to the cache manifest.

+4
source share
2 answers

Well, firstly, I believe that this bit of code should be placed inside the initializer, as this is just a configuration:

 Rack::Offline.configure do cache "images/masthead.png" public_path = Rails.public_path Dir[public_path.join("javascripts/*.js")].each do |file| cache file.relative_path_from(public_path) end network "/" end 

To answer your question about maintaining your compiled assets, they are accessible from a browser, so all you have to do is provide a cache instruction manually, and everything should work. Try using this configuration:

 Rack::Offline.configure do cache "assets/application.js" cache "assets/application.css" network "/" end 
+3
source

I had a similar problem, and I wrote a stone to solve the MD5 fingerprint problem.

https://rubygems.org/gems/assets_offline

+2
source

All Articles