title: Can't figure out this rails error: undefined method `remember_token=' for #<User:0x00000005e44238>?
body: <p>I gave my app an authentication system by follow Michael Hartl's tutorial, but I keep getting this remember_token method error: </p>
  
  <pre><code>undefined method `remember_token=' for #&lt;User:0x00000005e44238&gt;
  </code></pre>
  
  <p>I don't understand why remember_token is undefined because Hartl's tutorial says it automatically generated by the remember method I believe.</p>
  
  <p>Here is the application trace:</p>
  
  <pre><code>app/models/user.rb:23:in `remember'
  app/helpers/sessions_helper.rb:10:in `remember'
  app/controllers/sessions_controller.rb:11:in `create'
  </code></pre>
  
  <p>relevant user.rb:</p>
  
  <pre><code>def User.digest(string)
      cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
                                                BCrypt::Engine.cost
      BCrypt::Password.create(string, cost: cost)
  end
  
  def User.new_token
    SecureRandom.urlsafe_base64
  end
  
  def remember
    self.remember_token = User.new_token
    update_attribute(:remember_digest, User.digest(remember_token))
  
  
  end
  </code></pre>
  
  <p>sessions controller:</p>
  
  <pre><code>class SessionsController &lt; ApplicationController
  
    def new
    end
  
    def create
      user = User.find_by(email: params[:session][:email].downcase)
      if user &amp;&amp; user.authenticate(params[:session][:password])
      log_in user
      params[:session][:remember_me] == '1' ? remember(user) : forget(user)
      remember user
      redirect_back_or user
    else
       # Create an error message.
       flash.now[:danger] = 'Invalid email/password combination' # Not quite right!
       render 'new'
     end
     end
  
     def destroy
      forget(current_user)
      session.delete(:user_id)
      @current_user = nil
      redirect_to root_url
      end
      end
  </code></pre>
  
  <p>relevant sessions helper:</p>
  
  <pre><code>def remember(user)
    user.remember
    cookies.permanent.signed[:user_id] = user.id
    cookies.permanent[:remember_token] = user.remember_token
  end
  
  def forget(user)
    user.forget
    cookies.delete(:user_id)
    cookies.delete(:remember_token)
  end
  
  # Returns the current logged-in user (if any).
  def current_user
    if (user_id = session[:user_id])
      @current_user ||= User.find_by(id: user_id)
    elsif (user_id = cookies.signed[:user_id])
      user = User.find_by(id: user_id)
    if user &amp;&amp; user.authenticated?(cookies[:remember_token])
      log_in user
      @current_user = user
     end
    end
  
   end
  </code></pre>