Rails 3 devise, current_user is not accessible in a Model ?

This doesn’t make much sense, as you already pointed. The current_user doesn’t belong to model logic at all, it should be handled on the controller level.

But you can still create scope like that, just pass the parameter to it from the controller:

scope :instanceprojects, lambda { |user|
    where("projects.instance_id = ?", user.instance_id)
} 

Now you can call it in the controller:

Model.instanceprojects(current_user)

Leave a Comment