-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example on github page don't work #7
Comments
Hi Angelo, Try this: offline = Rails::Offline.configure do
public_path = Pathname.new(Rails.public_path)
Dir["#{public_path.to_s}/**/*"].each do |file|
cache Pathname.new(file).relative_path_from(public_path) if File.file?(file)
end
end Using Pathname.new gives Rack::Offline the expected type of object. Note that this is using Rails::Offline, a subclass of Rack::Offline that's provided with the Rack::Offline gem (this is where I found the solution). The Rails version sets the root to the Rails app's public root, among other things. Best, Alex |
Where should i put this configuration? I tried to put it into config/initializers/rack_offline.rb with the following but it doesn't work: offline = Rails::Offline.configure do
cache "Georgia.ttf"
public_path = Pathname.new(Rails.public_path)
Dir[
#"javascripts/*.js",
#"stylesheets/*.css",
#"images/*.*",
#"static/*.*",
File.join(public_path, "static/images/*.*")
].each do |file|
file = Pathname.new(file)
cache file.relative_path_from(public_path)
end
network "/"
end Thank you :-) |
@mareczek - I ended up putting it directly into my routes file: offline = Rails::Offline.configure do
# whatever
end
match "/application.manifest" => offline |
I have an issue, but i don't know if it's just with the manifest or with roadie. When i specify network: "/" my browser (chrome) in production caches also pages. I don't want it to cache pages :( Thanks! |
Hi there,
I found out that the example that was posted does not work (at least nog in 1.8.6 @ rails3).
I am reffering to this bit:
This gives two errors:
#1 .join does not work on a string.
#2 .relative_path_name is a method not known to string either
Here is a fixed version:
The text was updated successfully, but these errors were encountered: