Fallback Asset Gem
Create fallbacks to your assets. Helpful to work with development and cdn assets.
Installation
In your Gemfile:
gem 'fallback_assets'Features
- Add assets (javascripts / stylesheets) to your codebase with fallback to local files
- Great to use with CDN assets (first idea)
- The local asset will be used if the CDN is not available
- Easy to config
How to use
Single use
= fallback_javascript :underscore
= fallback_stylesheet :normalizeConfiguration
Create a file config/fallback_assets.yml under your rails app.
fallbacks:
stylesheets:
normalize:
production: //cdn/normalize.min.css
development: /assets/normalize.css
test: /assets/normalize.css
javascripts:
jquery:
production: //cdn/jquery.min.js
development: /assets/jquery.js
test: /assets/jquery.jsTips-for-Troubleshooting
If you are expecting errors while your tests are running, set the test environment like this:
...
underscore:
development: /assets/underscore.js
production: //whatevercdn/underscore.min.js
test: /assets/underscore.js # this is important, to access a file from vendor/assets/javascripts, use: /assetsLicense
MIT License © Djalma Araújo