The Refactoring Today I used move method to clean up a hack job I made a couple of months ago. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class KanbansController < ApplicationController def sync # Brute force update :) Issue.all.each do |issue| KanbanIssue.update_from_issue(issue) end respond_to do …
Tag: redmine
Daily Refactor #71: Extract Method in KanbansController to before_filter
The code in the Redmine Merge plugin looks pretty good so I’m going back to my Redmine Kanban plugin. Today’s refactoring was guided by the Rails Best Practices gem. This gem uses static code analysis to search for common smells in Rails applications. Running it on Redmine Kanban showed several smells I can tackle: ./app/controllers/kanbans_controller.rb:8,13 …
Daily Refactor #70: Inline Temp in SourceVersion#migrate
The Refactoring Today’s refactoring is just like yesterday’s but I wanted to show a quick tip with #create! I didn’t mention. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class SourceVersion < ActiveRecord::Base include SecondDatabase set_table_name :versions def self.migrate all.each do |source_version| v = Version.new v.attributes …
Daily Refactor #69: Inline Temp in SourceNews#migrate
I wanted to start refactoring my Redmine merge plugin now. I’m getting it ready for a release so doing a few refactorings now will help me make sure it’s working properly. The Refactoring Using inline temp I was able to clean up how the SourceNews#migrate converts data from one database to the other database. Before …
Daily Refactor #68: Extract Class to New Controller
The Refactoring Today I used extract class to move the #calendar method from IssuesController to it’s own controller. This is part of a large refactoring plan I have to get IssuesController slimmed down to a more manageable size. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 …