title: ruby on rails - current_user on model
body: <p>I need to call <code>current_user</code> on a model (I have installed <code>devise</code>).
  I use this method but it doesn't work:</p>
  
  <pre><code>class Todo
    def category_name
      category.try(:name)
    end
  
    def category_name=(name)
      self.category = Category.find_or_create_by(name: name, user_id: current_user)
    end
  
  end
  </code></pre>
  
  <p>how can I fix it?</p>