title: Method error when method called, but not as single line
body: <p>I have this method that reports an error at line 7. It runs fine when I enter each line separately in the console, but I get the error when I call the entire <code>deleteUser</code> method:</p>
  
  <blockquote>
    <p>NoMethodError: undefined method `delete' for nil:NilClass</p>
  </blockquote>
  
  <pre><code>1 def self.deleteUser(user_id)
  2  @user = User.where(:id =&gt; user_id).first
  3 players = GameMember.where(:user_id =&gt; @user.id, :is_game_over =&gt; "FALSE")
  4
  5 if players.empty?
  6  stat = Stat.where(:winners_id =&gt; @user.id).first
  7  unless stat.nil?
  8    stat.delete
  9 end
  
    ....
  </code></pre>