title: Devise 'user_signed_in?' not accessible from CanCan 'Ability' model
body: <p>I'm working on a Rails app and have Devise set up and working with all the default settings, and am setting up CanCan.</p>
  
  <p>The following is the content of the 'Ability' class, (not really my code, based on several tutorials);</p>
  
  <pre><code>class Ability
    include CanCan::Ability
  
    def initialize(user)
      user ||= User.new # guest user (not logged in)
      if user_signed_in?
          can :manage, :all
      end
    end
  end
  </code></pre>
  
  <p>I know the file itself works, as I've added a sample <code>authorize! :edit, @document</code> to one of my controllers. If I remove the <code>if user_signed_in?</code> line (and, of course, the <code>end</code>), then when the <code>can :manage, :all</code> line is present, I can access the <code>document</code> controller's actions, and without it, it says 'Access Denied'.</p>
  
  <p>However when I attempt to do this with the <code>user_signed_in?</code> line present, I get the following error;</p>
  
  <blockquote>
    <p>NoMethodError in DocumentsController#edit</p>
    
    <p>undefined method `user_signed_in?' for #</p>
  </blockquote>
  
  <p>And, interestingly, <code>user_signed_in?</code> works perfectly in my views, where I display a login box or the details of the currently logged in user with an <code>if</code> ... <code>else</code> block.</p>
  
  <p>Any ideas how I can access <code>user_signed_in?</code> here? In the longer term, I intend to read a value from the user's record to identify their access level, but it's important that the concept works, as the variables will be coming from the same place!</p>
  
  <p>Thanks!</p>