Tempname
Tempname

Reputation: 565

Namespaces and Routing

In my application I am using multilevel namespaces. For example I have the following controller:

class Admin::Userdesk::AccountsController < ApplicationController
  def show
      ....
  end

  def edit
      ....
  end
end

In my routes.rb I have the following:

namespace :admin do
    namespace :userdesk do
        resource :dashboards do
        end
        resource :accounts do 
        end
     end
end

An issue I am seeing is if I try to link to or navigate to /admin/userdesk/accounts/show/1 or /admin/userdesk/accounts/edit/1 I get the exceptions

No route matches [GET] "/admin/userdesk/accounts/show/1"

No route matches [GET] "/admin/userdesk/accounts/edit1"

I am not exactly sure where I muxed up my routing. Any help with this is greatly appreciated.

Upvotes: 1

Views: 108

Answers (1)

DanneManne
DanneManne

Reputation: 21180

Your problem is probably caused by the routes you are testing which is not rails standard. Try this:

Instead of /admin/userdesk/accounts/show/1 Try /admin/userdesk/accounts/1

And instead of /admin/userdesk/accounts/edit/1 Try /admin/userdesk/accounts/1/edit

Those should work with your current routes.

Edit:

I also noticed that you use resource in your routes.rb. You should probably change that to resources (plural).

Upvotes: 3

Related Questions