The Refactoring I’m still going off of the flay report for today, this time I’m tackling some duplication in the IssuesController. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 # app/controller/issues_controller.rb class IssuesController "#{Issue.table_name}.id"}.merge(@query.available_columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h})) # ... end def changes retrieve_query sort_init 'id', …
Category: Articles
Redmine Timesheet plugin v0.5.0 released
A new release of the Redmine Timesheet plugin has been tested and is ready for download. This release includes over 30 changes since the last release including 17 bug fixes and some new features like the CSV export. This will be the final version that is supported on Redmine 0.8, the next versions will require …
Daily Refactor #36: Extract Method to the Member model
The Refactoring Going back to the flay report, I used a combination of extract method and move method to move some duplication from a Controller to a shared Model method. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # app/controller/users_controller.rb class UsersController @user) @membership.attributes = params[:membership] @membership.save …
Daily Refactor #35: Pull up method for finding a controller’s model object
The Refactoring Now that yesterday’s split method is done, I can use pull up method to remove several similar before_filters. I had to add a declarative method (#model_object) so each controller can state which model should be used in the finders. Before 1 2 3 4 # app/controller/application_controller.rb class ApplicationController < ActionController::Base # ... end# …
Daily Refactor #34: Split Methods in the controllers
Back after a short personal break, I’m going to start on another set of refactorings in Redmine to remove some more duplication. The Refactoring This time I used split method to separate two behaviors in six similar before_filters. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 # app/controller/issue_relations_controller.rb class …