title: Use of current_user setter in Ruby on Rails Tutorial by Michael Hartl?
body: <p>I'm a little confused here. In <strong>chapter 8</strong> of the fabulous <a href="http://ruby.railstutorial.org/chapters/sign-in-sign-out#code-sign_in_success_not_yet_working" rel="nofollow"><strong>Ruby on Rails Tutorial</strong></a> by <em>Michael Hartl</em>, I can't figure out why Michael uses a setter to set the instance variable <code>@current_user</code> to <code>user</code>.</p>
  
  <pre><code>module SessionsHelper
  
    def sign_in(user)
      remember_token = User.new_remember_token
      cookies.permanent[:remember_token] = remember_token
      user.update_attribute(:remember_token, User.encrypt(remember_token))
      self.current_user = user
    end
  
    def current_user=(user)
      @current_user = user
    end
  end
  </code></pre>
  
  <p>Why did he not just skip the setter method and do it this way instead?</p>
  
  <pre><code>module SessionsHelper
  
    def sign_in(user)
      remember_token = User.new_remember_token
      cookies.permanent[:remember_token] = remember_token
      user.update_attribute(:remember_token, User.encrypt(remember_token))
      @current_user = user
    end
  end
  </code></pre>
  
  <p>Is it just because it's best practice to implement a setter or I don't get something?</p>