Redmine Refactor #141: Rename Method WikiController#page_index

After thinking about the REST API I want for WikiController, I decided that it needs to have an #index action so the user can get a list of the wiki pages. Looking over the actions, I found #page_index was already doing this so I used rename method to convert it over to #index.

Before

1
2
3
4
5
class WikiController < ApplicationController
  def page_index
    load_pages_grouped_by_date_without_content
  end
end
1
2
3
4
5
6
7
8
# config/routes.rb
  map.with_options :controller => 'wiki' do |wiki_routes|
    wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
      # ...
      wiki_views.connect 'projects/:project_id/wiki/page_index', :action => 'page_index'
      # ...
    end
  end

After

1
2
3
4
5
6
class WikiController < ApplicationController
  # List of pages, sorted alphabetically and by parent (hierarchy)
  def index
    load_pages_grouped_by_date_without_content
  end
end
1
2
3
4
5
6
7
8
# config/routes.rb
  map.with_options :controller => 'wiki' do |wiki_routes|
    wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
      # ...
      wiki_views.connect 'projects/:project_id/wiki/index', :action => 'index'
      # ...
    end
  end

Now I’m starting to see the WikiController starting to come together. I still think there are a bunch of misplaced actions in it, but the basic REST pattern is starting to emerge.

Reference commit