[rails5.1 / devise / administrative] Admin :: AdminUsers #index中的NameError

问题描述 投票:0回答:1

我正在努力解决错误(Admin :: AdminUsers#index中的NameError)

我正在使用设计和管理。我必须自定义设计控制器,所以设置一个控制器选项。

我的路线文件在这里。

Rails.application.routes.draw do
  devise_for :admin_users, path: :admin, skip: [:registration], :controllers => {
    :sessions => 'admin_users/sessions'
  }
  namespace :admin do
    root to: "admin_users#index"
    resources :admin_users
  end
end

但是,在设置:controller后,访问admin / path时会出现qazxsw poi。

错误细节:

parameter,ameError in Admin::AdminUsers#index

复制程序:

ActionView::Template::Error (uninitialized constant AdminUsers::Session):
10: <nav class="navigation" role="navigation">
11:   <% Administrate::Namespace.new(namespace).resources.each do |resource| %>
12:     <%= link_to(
13:       display_resource_name(resource),
14:       [namespace, resource_index_route_key(resource)],
15:       class: "navigation__link navigation__link--#{nav_link_state(resource)}"
16:     ) %>

你能告诉我错误发生的原因吗?

在设置控制器参数之前,它工作正常。

・access to /admin (and login screen is shown)
・enter e-mail address and pass and submit
・Error occur (after login success)

耙路线是一样的

Rails.application.routes.draw do
  devise_for :admin_users, path: :admin, skip: [:registration]
  namespace :admin do
    root to: "admin_users#index"
    resources :admin_users
  end
end
ruby-on-rails devise ruby-on-rails-5 administrative
1个回答
1
投票

从我看到你设置 Prefix Verb URI Pattern Controller#Action new_admin_user_session GET /admin/sign_in(.:format) devise/sessions#new admin_user_session POST /admin/sign_in(.:format) devise/sessions#create destroy_admin_user_session DELETE /admin/sign_out(.:format) devise/sessions#destroy root GET / admin/admin_users#index admin_root GET /admin(.:format) admin/admin_users#index admin_admin_users GET /admin/admin_users(.:format) admin/admin_users#index POST /admin/admin_users(.:format) admin/admin_users#create new_admin_admin_user GET /admin/admin_users/new(.:format) admin/admin_users#new edit_admin_admin_user GET /admin/admin_users/:id/edit(.:format) admin/admin_users#edit admin_admin_user GET /admin/admin_users/:id(.:format) admin/admin_users#show PATCH /admin/admin_users/:id(.:format) admin/admin_users#update PUT /admin/admin_users/:id(.:format) admin/admin_users#update DELETE /admin/admin_users/:id(.:format) admin/admin_users#destroy '我没有看到任何匹配你设置的路线。

我看到会话的路线正在跟随

:sessions => 'admin_users/sessions

我想你想添加 new_admin_user_session GET /admin/sign_in(.:format) devise/sessions#new admin_user_session POST /admin/sign_in(.:format) devise/sessions#create destroy_admin_user_session DELETE /admin/sign_out(.:format) devise/sessions#destroy ,否则你必须创建一个匹配你的devise/sessions的路线

© www.soinside.com 2019 - 2024. All rights reserved.