Permalink
Browse files

we need to access Rails.application.config

  • Loading branch information...
maccman committed Jan 28, 2012
1 parent e9a9c29 commit 8d39bb7b60467d22739b78fe5516c4a55bea998d
Showing with 9 additions and 10 deletions.
  1. +7 −7 lib/rack-offline.rb
  2. +2 −3 lib/rack/offline.rb
View
@@ -7,17 +7,18 @@ def self.call(env)
@app.call(env)
end
- def initialize(options = {}, &block)
- root = Rails.public_path
- block = cache_block(Pathname.new(root)) unless block_given?
+ def initialize(options = {}, app = Rails.application, &block)
+ config = app.config
+ root = config.paths['public'].first
+ block = cache_block(Pathname.new(root)) unless block_given?
opts = {
- :cache => config.cache_classes,
- :root => root,
+ :cache => config.cache_classes,
+ :root => root,
:logger => Rails.logger
}.merge(options)
- super opts, &block
+ super(opts, &block)
end
private
@@ -43,6 +44,5 @@ def cache_block(root)
network "/"
end
end
-
end
end
View
@@ -83,7 +83,6 @@ def precache_key!
def uncached_key
now = Time.now.to_i - Time.now.to_i % @cache_interval
Digest::SHA2.hexdigest(now.to_s)
- end
-
+ end
end
-end
+end

0 comments on commit 8d39bb7

Please sign in to comment.