Step 1: Create a new Rails app

gem install rails -v 4.1
rails new angular_example

Step 2: Remove Turbolinks

Removing turbolinks requires removing it from the Gemfile.

gem 'turbolinks'

Remove the require from app/assets/javascripts/application.js:

//= require turbolinks

Step 3: Add AngularJS to the asset pipeline

In order to get Angular to work with the Rails asset pipeline we need to add to the Gemfile:

gem 'angular-rails-templates'
gem 'bower-rails'

Now run the command

bundle install

Add bower so that we can install the AngularJS dependency:

rails g bower_rails:initialize json

Add Angular to bower.json:

{
  "name": "bower-rails generated dependencies",
  
  "dependencies": {

    "angular": "latest",
    "angular-resource": "latest",
    "bourbon": "latest",
    "angular-bootstrap": "latest",
    "angular-ui-router": "latest"
  }
}

Now that bower.json is setup with the right dependencies, let’s install them:

bundle exec rake bower:install

Step 4: Organize the Angular app

Create the following folder structure in app/assets/javascript/angular-app/: