I’m starting to refactor Redmine’s IssuesController
again. It’s a very cluttered controller that hasn’t been refactored as it’s grown, so I’ll need to build up my confidence with it over the next few refactorings. To start I used extract method to pull out a new useful utility method to the ApplicationController
.
Before
1
2
3
4
|
class IssuesController 'position')
@back = params[:back_url] || request.env['HTTP_REFERER']
end
end |
class IssuesController 'position')
@back = params[:back_url] || request.env['HTTP_REFERER']
end
end
1
2
3
|
class ApplicationController < ActionController::Base
# ...
end |
class ApplicationController < ActionController::Base
# ...
end
After
1
2
3
4
|
class IssuesController 'position')
@back = back_url
end
end |
class IssuesController 'position')
@back = back_url
end
end
1
2
3
4
5
|
class ApplicationController < ActionController::Base
def back_url
params[:back_url] || request.env['HTTP_REFERER']
end
end |
class ApplicationController < ActionController::Base
def back_url
params[:back_url] || request.env['HTTP_REFERER']
end
end
I’m still trying to figure out a good way to approach the rest of IssuesController
. I’m debating between splitting the controller and trying to move all of the queries to the models.
Reference commit