title: How to access current_user object in model?
body: <p>I am trying to write a method in my "team" model but current_user is showing this error </p>
  
  <p>undefined local variable or method `current_user' for #</p>
  
  <pre><code>def set_default_url
    if current_user.id == self.user_id
      "/assets/default_black_:style_logo.jpg"
    else
      "/assets/default_:style_logo.jpg"
    end
  end
  </code></pre>
  
  <p>The method current_user is working fine for other models and controllers . I am calling this method like this .</p>
  
  <pre><code>has_attached_file :logo, :styles =&gt; { 
    :medium =&gt; "200x200#", 
    :thumb =&gt; "100x100#", 
    :small =&gt; "50x50#" 
  }, 
  :default_url =&gt; :set_default_url
  </code></pre>
  
  <p>I am using rails 3.2 , ruby 1.9.3 and devise 3.1 . It seems to be simple task but I don't understand where the fault lies . I will be really thankful if someone helps me out here .</p>