acacia
acacia

Reputation: 1387

uninitialized constant UsersController

I am using devise and therefore do not need a users controller.However, i also need nested routes and my config.routes looks like this;

devise_for :admin_users, ActiveAdmin::Devise.config
  ActiveAdmin.routes(self)
  devise_for :users

  resources :users do 
    resources :personal_accounts,path: "user_account", only: [:show] do
      resources :deposits, only: [:new, :show, :create, :index]
      resources :withdraws, only: [:new, :show, :create, :index]
    end
    resources :businesses do
      resources :business_accounts, path: "business_account", only: [:show] do 
        resources :business_withdraws, only: [:new, :show, :create, :index]
        resources :business_deposits, only: [:new, :show, :create, :index]
      end
    end
  end

How can i go past this error while also maintaining my nested routes. Thank you.

Upvotes: 1

Views: 1033

Answers (1)

Matt Gibson
Matt Gibson

Reputation: 14949

You have three levels of nested routes there, which is normally considered to be undesirable: http://edgeguides.rubyonrails.org/routing.html#nested-resources

Resources should never be nested more than 1 level deep.

This bit resources :users do will create all the named routes for the users controller, which I suspect is where your error comes from. Why do you need this? Better perhaps to specify the routes without it?

resources :personal_accounts,path: "user_account", only: [:show] do
  resources :deposits, only: [:new, :show, :create, :index]
  resources :withdraws, only: [:new, :show, :create, :index]
end

Upvotes: 1

Related Questions