Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (20 sloc) 945 Bytes

Bounces or redirects requests to missing static files, allowing you to run a local server with a production database and have user uploaded content fetched transparently from the production site.

gem install rack-static_fallback

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

Example

# config/environments/development.rb
require 'rack/static_fallback'
config.middleware.use ::Rack::StaticFallback,
  :mode => :fallback,
  :static_path_regex => %r{/system/uploads},
  :fallback_static_url => "http://myproductionsite.com/"
Something went wrong with that request. Please try again.