Tag: refactoring

Daily Refactor #37: Extract Method to Query#sortable_columns

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', …

Read more

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# …

Read more