title: AngularJS routing with Rails
body: <p>I begin to use AngularJS with my Rails application but when i tried to implement my route providers with Angular, it's not working and Rails view is displayed instead of my template.</p>
  
  <p><strong>routes.rb</strong> :</p>
  
  <pre><code>root 'tutorials#index'
  </code></pre>
  
  <p><strong>TutorialsController</strong> :</p>
  
  <pre><code>    def index
      @tutorials = Tutorial.all
  
      respond_to do |format|
          format.html
          format.json { render :json =&gt; @tutorials }
      end
  end
  </code></pre>
  
  <p>app/views/tutorials/index.html.erb :</p>
  
  <pre><code>&lt;html ng-app="Tutorial"&gt;
  &lt;body&gt;
      &lt;div class="container" ng-view&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>assets/javascripts/tutorials.js :</p>
  
  <pre><code>var Tutorial = angular.module('Tutorial', ['ngRoute']);
  </code></pre>
  
  <p>Tutorial.config(function($routeProvider, $locationProvider){</p>
  
  <p>$log.debug( "Configuring $routeProvider...");</p>
  
  <pre><code>$locationProvider.html5Mode(true);
  
  $routeProvider.
  when('/tutorials', {
      templateUrl: '../templates/tutorials/index.html',
      controller: 'TutorialController'
  }).
  otherwise({
      templateUrl: '../templates/tutorials/index.html',
      controller: 'TutorialController'
  });
  </code></pre>
  
  <p>});</p>
  
  <p>and assets/templates/tutorials/index.html just displayed tutorials' title with a controller not shown in tutorials.js because it's not relevant here.</p>
  
  <p>So instead having my angular route provider redirect me to index.html, i have a blank page representing my index.html.erb.</p>
  
  <p>Any idea ?</p>
  
  <p>Thanks!</p>