title: Access user properties through a helper method in rails
body: <p>I wrote this helper method:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception
  
    private
  
    def current_user
      @current_user ||= User.find(session[:user_id]) if session[:user_id]
    end
    helper_method :current_user
  end
  </code></pre>
  
  <p>To which i should be able, in my mind, to do <code>current_user.role == 'some role'</code> but when I do that it spazzes out saying "undefined method role for nil:NilClass" now does that mean the role column is empty and has nothing it in or that the user object is empty? because I assure you I am logged in, I exist in the database and .... the role field in  the database is empty how ever.</p>
  
  <p><strong>Update</strong> I should probably state that doing <code>User.role == 'admin'</code> works, as their is a role attribute in the database, or well column. Why can't I do .role on current_user?</p>