0

I want to have to url /pc/group/1 point to views/groups/show.html.erb. I'm not sure how to do this. I tried the following:

namespace :pc do
    resources :groups
end

resources :pc

But it results in can't find the page.

1
  • What's the real message the server puts out? Perhaps your controller/action doesn't exists or your view is not available. EDIT: Please type rake routes in your terminal. The real route for this routes.rb should be /pc/groups/1 Commented Nov 18, 2013 at 18:17

1 Answer 1

2

You'd tell the route which controller and action to use in this situation:

namespace :pc, controller: 'groups' do
    resources :groups
end

resources :pc

Note that doing it this way, all routes for /pc/groups will point to the GroupsController, not just show.

Sign up to request clarification or add additional context in comments.

7 Comments

I have the following with rake routes: pc_group GET /pc/groups/:id(.:format) pc/groups#show However, when I go to the page it result in a page not found.
What is 'rat' in the above route?
Right, that's because your route shows the controller it's looking for is Pc::Groups#show, not Groups#show.
I have the following in my development.log: ActionController::RoutingError (uninitialized constant Pc::GroupsController), How can I fix it?
Exactly, because your route is looking for Pg::GroupsController but you only have a GroupsController - the Pg in the former is the namespace in your routes. Have you tried my change?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.