title: Sessions and rails: Sessions a undefined variable/method?
body: <p>So, I have this error:</p>
  
  <p><code>undefined local variable or method session for ApplicationController:Class</code></p>
  
  <p>So what I am guessing is rails, there is no "session" variable until it is  set, right?
  Or am I doing something wrong. This is the code using it:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    # Pre vent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception
  
    @account = User.find session[:userid]
  
  
  end
  </code></pre>
  
  <p>I set it in the login page. Would there be a way to only execute is it isn't nil, or would that not work as it is truly undefined? Am I checking sessions right?
  The code for setting sessions:</p>
  
  <pre><code>class SessionsController &lt; ApplicationController
    def login
    end
    def login_attempt
      authuser = User.auth(params[:name], params[:password])
      if authuser
        session[:userid] = authuser.id
          flash[:notice] = "We logged you in, #{authuser.name}!"
      else
          flash[:notice] = "INVALID USERNAME/PASSWORD!"
      end
    end
  </code></pre>
  
  <p>end</p>
  
  <p>So... Any ideas what this error message even means. I see there was a question like this, but that isn't the same, according to my testing (Or is it?)</p>