title: Trying to get "current user" in Rails
body: <p>In the <code>/views/layouts</code> directory, how do I get the current user? I am using Devise, but <code>current_user</code> does not work here for some reason, it describes it as an unknown method. I want to do something like:</p>
  
  <pre><code>&lt;% if User.role? == "gen_admin" %&gt;
      &lt;li&gt;
      &lt;%= link_to('Admin', users ) %&gt;
      &lt;/li&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I do have a <code>role?</code> method defined in my User model, but I still get this exception:</p>
  
  <p><code>undefined method 'role?' for #&lt;Class:0x3fcc1e0&gt;</code></p>
  
  <p>So how can I get the current user, and access its fields at this level of the source tree? Thanks!</p>
  
  <p>Here is the roles? method:</p>
  
  <pre><code># in User
  ROLES = %w[gen_admin teacher_admin student]
  def role?(base_role)
    ROLES.index(base_role.to_s) &lt;= ROLES.index(role)
  end
  </code></pre>