title: Uncaught TypeError: Cannot read property 'apply' of null onReadyStateChangeReplacement
body: <p>I'm building a Rails app with Angular built in.</p>
  
  <p>Everything's working just fine, but I've notice a strange error when I first land on one of my Angular-heavy pages after following a link. The Angular does not run -- the handlebars are visible despite ng_cloaks, etc -- and in the console I see this error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'apply' of null 
    onReadyStateChangeReplacement
  </code></pre>
  
  <p><strong>If I refresh, the page works fine!</strong> <em>Also if I just enter the url instead of following the link to that URL, it works fine</em>. So maybe this is a link/Turbolinks thing?</p>
  
  <p>It's Rails 4. I'm adapting a pattern of Angular integration described <a href="http://clintberry.com/2013/modular-angularjs-application-design/" rel="nofollow">here</a>. </p>
  
  <p>And I threw these lines into my application.coffee file (first in-app JS loaded) on advice to counteract Ng/Turbolinks not playing well together:</p>
  
  <pre><code>$(document).on 'page:load', -&gt;
    $('[ng-app]').each -&gt;
      module = $(this).attr('ng-app')
      angular.bootstrap(this, [module])
  </code></pre>
  
  <p>Any ideas what this might be? / What to look into?</p>
  
  <p>Thanks</p>