Scope from array only those objects in wich one of the users is current user
===

I am building a simple ToDo application, where I have Projects, who have many tasks, who have many subtasks. Users can be assigned to projects, tasks and subtasks.

In part of my app(on project show page), I wish to show tasks & subtasks that are overdue. I pick them with following code:

     35     @project_tasks = @project.tasks 
     36     @project_subtasks = @project.subtasks
     37   
     38     # OVERDUE
     39     @overdue_tasks = @project_tasks.overdue
     40     @overdue_subtasks = @project_subtasks.overdue
     41     @overdue_tasks_and_subtasks = @overdue_tasks + @overdue_subtasks
     42     @overdue_tasks_and_subtasks_sorted = @overdue_tasks_and_subtasks.sort_by {|object| object.target }

This shows overdue tasks and subtasks for all users on some project. However, I wish to have the option when the user clicks on a button, he only sees tasks and subtasks he is assigned to. So the following scope would be appropriate on line 43:

    @overdue_tasks_and_subtasks_from_current_user_sorted = @overdue_tasks_and_subtasks_sorted.where( #one of the users is the current_user )

How to write that scope?