Skip to content
Bounces or redirects requests to missing static files
Ruby
Find file
Pull request Compare This branch is 14 commits ahead, 1 commit behind dolzenko:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib/rack
Gemfile
README.md
Rakefile
rack-static_fallback.gemspec

README.md

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.