问题
can someone give me a quick solution please? I have done this: My routes:
offline = Rack::Offline.configure do
cache ActionController::Base.helpers.asset_path("application.css")
cache ActionController::Base.helpers.asset_path("application.js")
cache ActionController::Base.helpers.asset_path("jquery.min.css")
cache ActionController::Base.helpers.asset_path("jquery.tmpl.min.css")
cache ActionController::Base.helpers.asset_path("style.js")
# cache ActionController::Base.helpers.asset_path("custom.css")
network "/"
end
get "/application.manifest" => offline
in application.html.erb:
<html manifest="/application.manifest">
in my gemfile:
# gem 'rack-offline'
# gem 'rack-offline', :github => 'pascalw/rack-offline'
gem 'rack-offline', :git => 'https://github.com/wycats/rack-offline.git'
my Rails version: 4.1.6
, Ruby version: 2.1.3
this is the output at http://localhost:3000/application.manifest
is:
CACHE MANIFEST
# a5a8232b037b9e6234e3db79ab4b2bff8fffecd76c4124f456273146f70631b0
/assets/application.css
/assets/application.js
NETWORK:
/
I have also added ENV["RAILS_ASSET_ID"] = ""
in application.rb as rails cast #247 Offline Apps Part 1.
Please someone advise what I am doing wrong??
回答1:
routes.rb
offline = Rack::Offline.configure do
#cache "images/masthead.png"
cache ActionController::Base.helpers.asset_path("jquery.js")
cache ActionController::Base.helpers.asset_path("jquery_ujs.js")
cache ActionController::Base.helpers.asset_path("application.css")
cache ActionController::Base.helpers.asset_path("application.js")
cacheActionController::Base.helpers.asset_path("jquery.offline.js")
cache ActionController::Base.helpers.asset_path("jquery.tmpl.min.js")
cache ActionController::Base.helpers.asset_path("json.js")
cache ActionController::Base.helpers.asset_path("offline_mode.js")
network "/"
end
get "/application.manifest" => offline
applicaiton.js something like this
//= require jquery
//= require jquery_ujs
//= require jquery.tmpl.min
//= require jquery.offline
//= require json
//= require offline_mode
//= require_tree .
来源:https://stackoverflow.com/questions/26248279/rackoffline-in-rails-4-1-issue