Permalink
Browse files

fix rails support for rails >= 3.1 with assets pipeline

  • Loading branch information...
1 parent 77d1140 commit aa61d74b62dae0d4f60eeb0963e012174f3653b8 @tchak tchak committed Oct 16, 2011
Showing with 11 additions and 5 deletions.
  1. +11 −5 lib/rack-offline.rb
View
16 lib/rack-offline.rb
@@ -26,11 +26,17 @@ def initialize(options = {}, app = Rails.application, &block)
def cache_block(root)
Proc.new do
- files = Dir[
- "#{root}/**/*.html",
- "#{root}/stylesheets/**/*.css",
- "#{root}/javascripts/**/*.js",
- "#{root}/images/**/*.*"]
+ if Rails.version >= "3.1" && Rails.configuration.assets.enabled
+ files = Dir[
+ "#{root}/**/*.html",
+ "#{root}/assets/**/*.{js,css,jpg,png,gif}"]
+ else
+ files = Dir[
+ "#{root}/**/*.html",
+ "#{root}/stylesheets/**/*.css",
+ "#{root}/javascripts/**/*.js",
+ "#{root}/images/**/*.*"]
+ end
files.each do |file|
cache Pathname.new(file).relative_path_from(root)

0 comments on commit aa61d74

Please sign in to comment.