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 …
Tag: refactoring
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 …
Redmine Refactor #125: Split UsersController#edit into #edit and #update
Working my way through the UsersController class, the next method that needs to be refactored is #edit. This method has the common problem of both: rendering the edit form also accepting the POST data from the form To fit the REST pattern, this needs to be split into separate #edit and #update methods. Before 1 …