rack::offline in rails 4.1 Issue

﹥>﹥吖頭↗ 提交于 2019-12-11 20:31:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!