如何修复似乎不起作用的 ActiveAdmin 'Edit'操作路由



我刚刚创建了活动的管理面板,一切似乎都正常,但在创建新的管理用户时,我收到了URLGeneration错误,尽管用户是在返回面板时创建的。当我尝试"查看"我刚刚创建的用户或包括默认管理员用户在内的任何用户时,也会出现同样的错误。当我点击管理用户的"Id"时也是如此。

(错误(

ActionController::UrlGenerationError in Admin::AdminUsers#show
showing .../bundler/gems/activeadmin-b9f189ff671a/app/views/active_admin/resource/show.html.arb where line #2 raised:
No route matches {:action=>"edit", :controller=>"admin/admin_users", :id=>#<User id: nil, email: "", created_at: nil, updated_at: nil, name: nil, provider: nil, uid: nil, image: nil>}, possible unmatched constraints: [:id]

(配置/路由.rb(

Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)

(型号/admin_user.rb(

class AdminUser < ApplicationRecord
devise :database_authenticatable, 
:recoverable, :rememberable, :validatable
end

管理文件:

(admin/admin_users.rb(

ActiveAdmin.register AdminUser do
permit_params :email, :password, :password_confirmation
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at
form do |f|
f.inputs do
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end
end

(admin/dashboard.rb(

ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
content title: proc{ I18n.t("active_admin.dashboard") } do
div class: "blank_slate_container", id: "dashboard_default_message" do
span class: "blank_slate" do
span I18n.t("active_admin.dashboard_welcome.welcome")
small I18n.t("active_admin.dashboard_welcome.call_to_action")
end
end
end # content
end
No route matches {
:action=>"edit", 
:controller=>"admin/admin_users", 
:id=>#<User id: nil, email: "", created_at: nil, updated_at: nil, name: nil, provider: nil, uid: nil, image: nil>
}, possible unmatched constraints: [:id]

我对以上内容的理解是,edit路由需要一个ID,但却得到了一个坏值。结合这个

ActionController::UrlGenerationError in Admin::AdminUsers#show

通过您对所做操作的描述,我相信在show视图中生成edit链接的方式存在问题。

你能更新你的问题以包括ActiveAdmin的"显示"视图吗?包含ActiveAdmin资源文件(应该在app/admin中(也会很有帮助。

相关内容

  • 没有找到相关文章

最新更新