Posted almost 5 years ago. Visible to the public. Linked content.

Managing vendor assets in Rails with Bower

bower-rails is a great solution for managing vendored assets in your Rails app. It feels especially much more convenient and easier to update assets when going this way.

bower-rails generates a Bowerfile that works much like the Gemfile you're used to. Just specify your dependencies and run rake bower:install. You can find available packages here.

An example Bowerfile:

Copy
# ./Bowerfile asset 'angular' asset 'angular-i18n' asset 'angular-ui-router' asset 'angular-ui-bootstrap' asset 'lodash' asset 'restangular' asset 'moment', '1.2.3'

The following commands are available via rake (there are more, these are the main ones only):

Copy
$ rake -T | grep bower # => rake bower:install # Install components from Bowerfile rake bower:list # List bower components rake bower:update[<component>] rake bower:update:prune # Update existing components and uninstalls extraneous components

To update multiple (but not all) components, you can run rake bower:update with a comma separated list of components:

Copy
rake bower:update[angular,angular-i18,angular-cookies,angular-animate,angular-sanitize,angular-mocks]

Also see bower-rails can rewrite your relative asset paths.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Thomas Klemm
Last edit:
over 2 years ago
by Judith Roth
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Thomas Klemm to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more