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