Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow custom controller for resource(s) [#3703 state:resolved]

  • Loading branch information...
commit e9a1dbe79a6610793a71af227aaf64ff55554cad 1 parent 468cfce
Joshua Peek josh authored
2  actionpack/lib/action_dispatch/routing/mapper.rb
View
@@ -380,7 +380,7 @@ def name
end
def controller
- plural
+ options[:controller] || plural
end
def member_name
20 actionpack/test/dispatch/routing_test.rb
View
@@ -65,7 +65,7 @@ def self.matches?(request)
resources :companies do
resources :people
- resource :avatar
+ resource :avatar, :controller => :avatar
end
resources :images do
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.