Finally, today I was able to refactor enough of TimelogController in order to start removing the extra code from #edit. Using extract method I pulled out the #update method that will perform the actual database saves for a TimeEntry. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 …
Tag: extract-method
Redmine Refactor #130: Extract Method TimelogController#edit to TimelogController#new
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) …
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 #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 #118: Split Edit Method in NewsController
Following up to yesterday’s refactoring of NewsController#new, today I’m using split method again but on #edit. #edit is both rendering the form for editing a news item as well as accepting the form submission and saving it to the database. To work with RESTful Rails, it needs to be split into #edit and #update. Before …