rack :: offline in rails 4.1问题 [英] rack::offline in rails 4.1 Issue

查看:107
本文介绍了rack :: offline in rails 4.1问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我快速解决方案吗?我已经做到了: 我的路线:

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

在application.html.erb中:

in application.html.erb:

<html manifest="/application.manifest">

在我的gemfile中:

in my gemfile:

# gem 'rack-offline'
# gem 'rack-offline', :github => 'pascalw/rack-offline'
gem 'rack-offline', :git => 'https://github.com/wycats/rack-offline.git'

我的Rails version: 4.1.6Ruby version: 2.1.3

这是http://localhost:3000/application.manifest的输出是:

CACHE MANIFEST
# a5a8232b037b9e6234e3db79ab4b2bff8fffecd76c4124f456273146f70631b0
/assets/application.css
/assets/application.js

NETWORK:
/

我还在application.rb中将 ENV["RAILS_ASSET_ID"] = "" 添加为 rails cast#247离线应用程序第1部分. 请有人告诉我我在做什么错吗?

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??

推荐答案

routes.rb

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类似

applicaiton.js something like this

//= require jquery
//= require jquery_ujs
//= require jquery.tmpl.min
//= require jquery.offline
//= require json
//= require offline_mode
//= require_tree .

这篇关于rack :: offline in rails 4.1问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆