Rails admin 未初始化常量 Country::Person

kir*_*rqe 2 ruby-on-rails activeadmin

当我单击rails_admin 导航中的国家/地区时,我得到

NameError in RailsAdmin::Main#index

uninitialized constant Country::Person

raise NameError.new("uninitialized constant #{candidates.first}", candidates.first)
Run Code Online (Sandbox Code Playgroud)

我使用的是用户模型而不是人员。我想我需要以某种方式配置它。但到哪里去做呢?

这是我的 Rails 管理初始化程序

  ## == Devise ==
   config.authenticate_with do
     warden.authenticate! scope: :user
   end
   config.current_user_method(&:current_user)

  ## == Cancan ==
   config.authorize_with :cancan 

  ### More at https://github.com/sferik/rails_admin/wiki/Base-configuration

  config.model "User" do
      edit do
        field :admin
        field :username
        field :email
        field :password
      end
    end

  config.actions do
    dashboard                     # mandatory
    index                         # mandatory
    new
    export
    bulk_delete
    show
    edit
    delete
    show_in_app

    ## With an audit adapter, you can add:
    # history_index
    # history_show
  end
Run Code Online (Sandbox Code Playgroud)

jef*_*150 5

我也遇到了这个问题,但这不是由于失去关联造成的。当我创建模型时,我错误地使用了模型名称的复数形式:它是Things而不是Thing.

things.rb我通过将fromThings中的类名更改为Thing并将文件重命名为thing.rb.