Redmine Refactor #112: Split Method in FilesController

The next step to refactor Redmine’s ProjectsController is to start converting all of it’s related resources into RESTful controllers. Looking at config/routes.rb, it looks like FilesController is using three custom routes that hang off of ‘/projects/’ and the #new action is being used for both HTTP GET and HTTP POST. So I’ll use split method to convert #new into two separate actions

Before

1
2
3
4
5
6
class FilesController  'files', :action => 'index', :id => @project
      return
    end
    @versions = @project.versions.sort
  end
end

After

1
2
3
class FilesController  'files', :action => 'index', :id => @project
  end
end

Now with FilesController following the Rails REST pattern a bit more, I can go back and modify the routes.rb file and move FilesController to be a child resource of projects.

Reference commit

Share

  • Facebook
  • Twitter
  • HackerNews
  • Reddit
  • Tumblr
  • Delicious
  • Email
  • RSS

Related posts:

  1. Redmine Refactor #118: Split Edit Method in NewsController
  2. Redmine Refactor #117: Split New Method in NewsController
  3. Redmine Refactor #115: Split Method in VersionsController
  4. Redmine Refactor #114: Split Method in VersionsController
  5. Redmine Refactor #140: Extract Method WikiController#edit to #update

About Eric Davis

I founded Little Stream Software where I provide Redmine and ChiliProject services to help projects teams. I also created an ebook, Redmine Tips, were I show you how to become more productive using Redmine. I am also the author of Refactoring Redmine, where I go about refactoring Rails using Redmine as an example.

, , , ,

Chirk HR     Reuse your existing job applicants »
WP Socializer Aakash Web