Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove ActiveRecord dependency, validate options sanity in initialize

  • Loading branch information...
commit 3a889faf221fc9f89f8a9f17e9a73fcc0537a99c 1 parent ac16807
@dolzenko authored
Showing with 7 additions and 9 deletions.
  1. +7 −9 lib/rack/static_fallback.rb
View
16 lib/rack/static_fallback.rb
@@ -31,7 +31,11 @@ def initialize(app, options = {})
@mode = options[:mode] || :off
# along the lines of the Capistrano defaults
@static_path_regex = options[:static_path_regex] || %r{/system/(audios|photos|videos)}
- @fallback_static_url = options[:fallback_static_url]
+ @fallback_static_url = options[:fallback_static_url]
+
+ if @mode == :fallback && !@fallback_static_url
+ raise ArgumentError, "Rack::StaticFallback :mode => :fallback option specified without :fallback_static_url option"
+ end
end
def call(env)
@@ -49,14 +53,8 @@ def call(env)
not_found
when :fallback
- if @fallback_static_url
- # redirect request to the production server
- [ 302, { "Location" => ::File.join(@fallback_static_url, env["PATH_INFO"]) }, [] ]
- else
- ActionController::Base.logger.debug "You're using StaticFallback middleware with StaticFallback.mode set to :fallback " <<
- "however StaticFallback.fallback_static_url has not been set."
- not_found
- end
+ # redirect request to the production server
+ [ 302, { "Location" => ::File.join(@fallback_static_url, env["PATH_INFO"]) }, [] ]
end
else
Please sign in to comment.
Something went wrong with that request. Please try again.