Looking through Redmine’s ProjectsController, I found a few actions that were being used to manage project files. These files are separate resources on a project so using move method and extract class I created a new controller, FilesController. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class ProjectsController …
Tag: move-method
Redmine Refactor #102: Move method from ProjectsController#roadmap to VersionsController#index
The next refactoring I performed on Redmine’s ProjectsController was to move the #roadmap method to VersionsController. The #roadmap is used to list all Versions on a project. Since that fits Rails’ RESTful conventions for #index, I used move method to move it to the VersionsController. Before 1 2 3 4 5 6 7 8 9 …
Redmine Refactor #97: Move method from IssuesController to JournalsController
Starting a fresh week, it’s time to finish up refactoring IssuesController to remove the last of the extra actions. Using move method I was able to move the #changes method to the JournalsController. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class IssuesController …
Redmine Refactor #92: Move Method #reply to JournalsController
Looking over the public methods in IssuesController now, I see that the #reply method is out of place. It’s used to quote a new reply on an issue but it does this via a journal. Since Redmine already has a JournalsController that is used when a journal is edited, it makes more sense to move …
Daily Refactor #81: Move last_invoice_number to Model
The Refactoring Today I used move method on the InvoiceController to move the #last_invoice_number to the Invoice model Before 1 2 3 4 5 6 7 8 class InvoiceController 'id DESC') unless last_invoice.nil? last_invoice.invoice_number else '-' end end endclass InvoiceController 'id DESC') unless last_invoice.nil? last_invoice.invoice_number else '-' end end end 1 2 3 class Invoice …