[英]How to set up rack-offline in rails 3.2 app
How to make rake-offline work in rails 3.2.11 ? 如何在Rails 3.2.11中使脱机工作?
I added initializer 我添加了初始化器
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
I added in routes 我在路线中添加了
match "/application.manifest" => Rails::Offline
Rack::Offline.configure do
cache "assets/application.js"
cache "assets/application.css"
network "/"
end
and added manifest in html tag. 并在html标签中添加清单。
It throws error 引发错误
/initializers/offline.rb:5:in `block in <top (required)>': undefined method `join' for "/Sites/Ruby/project/public":String (NoMethodError)
In Rails 3.2.11, Rails.public_path
returns a String
, not a Pathname
object. 在Rails 3.2.11中,
Rails.public_path
返回String
,而不是Pathname
对象。 (It looks like Rails master has it returning a Pathname
object which is why rack-offline's documentation might say to use it that way). (看起来Rails master会返回一个
Pathname
对象,这就是为什么机架脱机文档可能会说要使用它的原因)。
Try this instead: 尝试以下方法:
public_path = Pathname.new(Rails.public_path)
See https://github.com/wycats/rack-offline/issues/7 参见https://github.com/wycats/rack-offline/issues/7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.