I need to call current_user
on a model (I have installed devise
).
I use this method but it doesn't work:
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
how can I fix it?