The Refactoring
After a two hour Developer Meeting for Redmine this morning, I’m too drained to tackle the entire refactoring for #find_optional_project. I did use pull up method to remove the duplication in the GanttsController and IssuesController though.
Before
1 2 3 4 5 6 7 | # app/controllers/issues_controller.rb class IssuesController params[:controller], :action => params[:action]}, @project, :global => true) allowed ? true : deny_access rescue ActiveRecord::RecordNotFound render_404 end end |
1 2 3 4 5 6 7 | # app/controllers/gantts_controller.rb class GanttsController params[:controller], :action => params[:action]}, @project, :global => true) allowed ? true : deny_access rescue ActiveRecord::RecordNotFound render_404 end end |
1 2 3 4 | # app/controllers/application_controller.rb class ApplicationController < ActionController::Base # ... end |
After
1 2 3 4 | # app/controllers/issues_controller.rb class IssuesController < ApplicationController # ... end |
1 2 3 4 | # app/controllers/gantts_controller.rb class GanttsController < ApplicationController # ... end |
1 2 3 4 5 6 7 | # app/controllers/application_controller.rb class ApplicationController params[:controller], :action => params[:action]}, @project, :global => true) allowed ? true : deny_access rescue ActiveRecord::RecordNotFound render_404 end end |
Review
This finishes up my refactoring of the GanttsController. I’m leaving the refactoring of the other duplicated #find_optional_project methods for another time.
Share
Related posts:
- Redmine Refactor #91: Pull Up set_flash_from_bulk_issue_save to ApplicationController
- Redmine Refactor #90: Pull Up Method to ApplicationController
- Daily Refactor #66: Pull Up Method to ApplicationController
- Daily Refactor #36: Extract Method to the Member model
- Daily Refactor #35: Pull up method for finding a controller’s model object
