Yesterday’s refactoring of TimelogController#edit took care of it’s first action. Now I need to use extract method again to pull out the “save new TimeEntry” action (#create). Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 class TimelogController [:new, :edit, :destroy] def edit (render_403; return) …
Category: Articles
Redmine Refactor #129: Extract Method TimelogController#edit to TimelogController#new
In this refactoring I’m using extract method to split up the TimelogController#edit method. Right now it’s handling four separate actions: Display an empty form for a new TimeEntry Save a new TimeEntry Display a form for an existing TimeEntry Save an existing TimeEntry Normally these would be separate RESTful Rails actions; #new, #create, #edit, and …
Redmine Refactor #128: Rename method TimelogController#details to #index
After yesterday’s refactoring of #report I’ve given a lot of thought to what should happen to the #details method. At it’s core, it’s just listing all of the TimeEntries so I think it’s actually an #index method in disguise. To refactor this I used rename method. Before 1 2 3 4 5 6 7 8 …
Redmine Refactor #127: Extract TimelogController#report to new TimeEntryReportsController
Since UsersController was refactored to a resource yesterday, I started on the TimelogController today. TimelogController has a really messy list of actions: Two reporting methods (#report and #details) #edit handles 4 actions for TimeEntries: form for new record, form for an existing record, saving a new record, and updating an existing record. No #index or …
Redmine Refactor #126: Convert UsersController to Resource
Today I decided to go ahead and convert UsersController to a REST resource. There were two non-standard methods left (#edit_membership and #destroy_membership) but I can’t see a clear way to refactor them yet. So I just converted the controller to a resource and added those methods as member routes. Before 1 2 3 4 5 …