我正在使用设计,因此不需要用户控制器。但是,我还需要嵌套路由,我的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
如何在保持嵌套路由的同时通过此错误。 谢谢。
答案 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