Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Bounces or redirects requests to missing static files
tag: v1.0.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Bounces or redirects requests to missing static files. Partially inspired by

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.

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

Install via rubygems:

gem install rack-static_fallback

then, for Rails (any version which supports Rack) apps, 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 => ""

note that Rails 3 won't auto-load the gem files, so you may need to

require 'rack/static_fallback'

at the beginning of 'development.rb'. Aternatively, you should also be able to use the gem in non-Rails apps with:

use ::Rack::StaticFallback, :mode => :fallback,
                            :static_path_regex => %r{/system/uploads},
                            :fallback_static_url => ""

in your '' (this is untested so mileage may vary)

Something went wrong with that request. Please try again.