未初始化的常量UsersController

时间:2015-05-06 15:51:05

标签: ruby-on-rails ruby-on-rails-4 devise

我正在使用设计,因此不需要用户控制器。但是,我还需要嵌套路由,我的config.routes看起来像这样;

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

如何在保持嵌套路由的同时通过此错误。 谢谢。

1 个答案:

答案 0 :(得分:1)

您有三个级别的嵌套路线,通常被认为是不受欢迎的:http://edgeguides.rubyonrails.org/routing.html#nested-resources

  

资源不应该嵌套超过1级。

此位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