Rails Assets

The solution to assets management in Rails

Rails Assets is the frictionless proxy between Bundler and Bower.

It automatically converts the packaged components into gems that are easily droppable into your asset pipeline and stay up to date.

Getting started

Bundler

Add https://rails-assets.org as the new gem source, then reference any Bower components that you need as gems in the following convention:

gem 'rails-assets-BOWER_PACKAGE_NAME'

During bundle install, if Bundler requests a package like this, Rails Assets’ daemon automatically will:

  • fetch the component from Bower’s registry,
  • analyze its manifest file, bower.json,
  • repackage the component as a valid Ruby gem and serve it to your application.

Dependencies are handled the same way recursively.

Gemfile

 source 'https://rubygems.org'
+source 'https://rails-assets.org'

 gem 'rails'

 # Assets
 gem 'sass-rails'
 gem 'uglifier'
 gem 'coffee-rails'
+gem 'rails-assets-bootstrap'
+gem 'rails-assets-angular'
+gem 'rails-assets-leaflet'
 

Asset pipeline

You can now require BOWER_PACKAGE_NAME in your stylesheets and JavaScript files—all assets exposed as main in bower.json will be automatically included.

Gems created by Rails Assets work great with any Sprockets-based application.

application.js

 //= require_self
+//= require bootstrap
+//= require angular
+//= require leaflet
 //= require_tree .
 //= require_tree shared
application.css

 /*
  *= require_self
+ *= require bootstrap
+ *= require leaflet
  *= require_tree .
  *= require_tree shared
  */
beta