If the find is being performed several times throughout the application then there will be duplication. One way to remove this duplication is to move the find into the model, which would allow us to call
@tasks = Task.find_incomplete
in the controller. To do this we’ll need to create a new method in the model. The method has to be a class method so must start with self.
There’s no need to specify Task in the find line as the find is already scoped inside the Task class. Now you can call Task.find_incomplete whenever you need to perform that find. This will even work in associations so that you can find Project’s incomplete tasks like this: