Move a find into the model to clean up the controllers and remove duplication. Also see how you can call these custom find methods through an association.
Learn how to clean up your code through refactoring. This episode will show you how to move code from the view into the model to remove duplication and simplify the view.
Testing and refactoring go hand in hand. Refactoring is all about improving code without changing its behavior. Testing is all about making sure you don't change the behavior while you are improving the code.
In the final part of this series you will see how to refactor your tests. Keeping tests clean is important because it will make testing easier to do in the future.
In this episode I walk you through an exercise in refactoring by taking a long method and making it more concise.
If you have complex view logic, this can easily lead to helper methods which call each other. See how to refactor this out into another object in this episode.