title: Rails 3 devise, current_user is not accessible in a Model ?
body: <p>in my project.rb model, I'm trying to create a scope with a dynamic variable:</p>
  
  <pre><code>scope :instanceprojects, lambda { 
      where("projects.instance_id = ?", current_user.instance_id)
  } 
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>undefined local variable or method `current_user' for #&lt;Class:0x102fe3af0&gt;
  </code></pre>
  
  <p>Where in the controller I can access <code>current_user.instance_id</code>... Is there a reason the model can't access it and a way to get access? Also, is this the right place to create a scope like the above, or does that belong in the controller?</p>