StaticFallback
Added by dolzenko
at March 25, 2010 11:17
GitHub stats:
watcher(s)
fork(s)
About
Bounces or redirects requests to missing static files. Partially inspired by http://menendez.com/blog/using-django-as-pass-through-image-proxy/
I.e. could be useful when you want to run the server with production database locally and have user uploaded content fetched transparently from production site.
Usage
Options:
:mode - [ :off,
:bounce, # returns 404 to any request to static URL,
:fallback ] # any request to static path is redirected to :fallback_static_url
:static_path_regex - Regexp which matches the path to your static files.
Along the lines of the Capistrano conventions defaults to `%r{/system/(audios|photos|videos)}`
:fallback_static_url - URL of the production site
To use with Rails install as a plugin:
script/plugin install git://github.com/dolzenko/rack-static_fallback.git
then add the following to your config/environments/development.rb
config.middleware.insert_after ::Rack::Lock,
::Rack::StaticFallback, :mode => :fallback,
:static_path_regex => %r{/system/uploads},
:fallback_static_url => "http://myproductionsite.com/"

