Skip to content

Commit

Permalink
Allow custom controller for resource(s) [#3703 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 16, 2010
1 parent 468cfce commit e9a1dbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -380,7 +380,7 @@ def name
end

def controller
plural
options[:controller] || plural
end

def member_name
Expand Down
20 changes: 10 additions & 10 deletions actionpack/test/dispatch/routing_test.rb
Expand Up @@ -65,7 +65,7 @@ def self.matches?(request)

resources :companies do
resources :people
resource :avatar
resource :avatar, :controller => :avatar
end

resources :images do
Expand Down Expand Up @@ -294,34 +294,34 @@ def test_global
def test_projects
with_test_routes do
get '/projects'
assert_equal 'projects#index', @response.body
assert_equal 'project#index', @response.body
assert_equal '/projects', projects_path

post '/projects'
assert_equal 'projects#create', @response.body
assert_equal 'project#create', @response.body

get '/projects.xml'
assert_equal 'projects#index', @response.body
assert_equal 'project#index', @response.body
assert_equal '/projects.xml', projects_path(:format => 'xml')

get '/projects/new'
assert_equal 'projects#new', @response.body
assert_equal 'project#new', @response.body
assert_equal '/projects/new', new_project_path

get '/projects/new.xml'
assert_equal 'projects#new', @response.body
assert_equal 'project#new', @response.body
assert_equal '/projects/new.xml', new_project_path(:format => 'xml')

get '/projects/1'
assert_equal 'projects#show', @response.body
assert_equal 'project#show', @response.body
assert_equal '/projects/1', project_path(:id => '1')

get '/projects/1.xml'
assert_equal 'projects#show', @response.body
assert_equal 'project#show', @response.body
assert_equal '/projects/1.xml', project_path(:id => '1', :format => 'xml')

get '/projects/1/edit'
assert_equal 'projects#edit', @response.body
assert_equal 'project#edit', @response.body
assert_equal '/projects/1/edit', edit_project_path(:id => '1')
end
end
Expand Down Expand Up @@ -383,7 +383,7 @@ def test_projects_companies
assert_equal '/projects/1/companies/1/people', project_company_people_path(:project_id => '1', :company_id => '1')

get '/projects/1/companies/1/avatar'
assert_equal 'avatars#show', @response.body
assert_equal 'avatar#show', @response.body
assert_equal '/projects/1/companies/1/avatar', project_company_avatar_path(:project_id => '1', :company_id => '1')
end
end
Expand Down

0 comments on commit e9a1dbe

Please sign in to comment.