title: NoMethodError in Scores#index
body: <p>In my game the a user <code>has_one</code> score and a score <code>belongs_to</code> a user. As the user is playing, I want the score of that user to be visibily incrementing by 1 every second, and then be saved so that the user's score can be visible on a leaderboard. I have already figured out the code to do this with a JavaScript variable, however when I try it with a ruby object I get an error saying: </p>
  
  <pre><code>undefined method '+' for nil:NilClass
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>class ScoresController &lt; ApplicationController
    before_action :require_user, only: [:index]
  
    def index
        @score = current_user.score
        @users = User.all
    end
  end
  </code></pre>
  
  <p>View:   </p>
  
  <pre><code>&lt;div class="score-outline"&gt; Score:&lt;div id="score"&gt;0&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>window.setInterval(
  function countscore() {
      if($('#game-area').is(':animated')){    
          &lt;%= @score += 1 %&gt;
          document.getElementById("score").innerHTML = &lt;%= @score %&gt;
      }
  }, 1000); 
  </code></pre>