Configuring Rails and Angular

To start using Angular with Rails, we mostly just need to install Angular using Bower, and arrange for Angular’s code to be served up by the asset pipeline. First, we’ll add Angular to Bowerfile.

 asset 'bootstrap-sass-official'
 # START_HIGHLIGHT
 # END_HIGHLIGHT
 asset 'angular', '~> 1.5'
 resolution 'angular', '1.5'

Note the use of the resolution keyword. Bower isn’t as sophisticated as Bundler at handling dependencies, and when it isn’t 100% sure what version of something to grab, it asks you, interactively. This is somewhat inconvenient, so you can specify a specific version to use for a specific asset. In this case, it does look confusing, because we really only have ...

Get Rails, Angular, Postgres, and Bootstrap now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.