My guest post The First Step of Refactoring a Rails Application was just posted to RailsInside.com last night. I’m going to write more posts in the series over the next few weeks. If you have a refactoring question that you want me to answer, let me know in the comments.
Tag: ruby
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 #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 …