Ruby on rails 管理员::用户#索引中的名称错误

Ruby on rails 管理员::用户#索引中的名称错误,ruby-on-rails,ruby-on-rails-4,activeadmin,Ruby On Rails,Ruby On Rails 4,Activeadmin,当我想用ActiveAdmin删除一个用户时,我得到以下错误: PG::ForeignKeyViolation: ERROR: update or delete on table "users" violates foreign key constraint "fk_rails_18841639d7" on table "recherches" DETAIL: Key (id)=(5) is still referenced from table "recherches". : DELETE F

当我想用ActiveAdmin删除一个用户时,我得到以下错误:

PG::ForeignKeyViolation: ERROR: update or delete on table "users" violates foreign key constraint "fk_rails_18841639d7" on table "recherches" DETAIL: Key (id)=(5) is still referenced from table "recherches". : DELETE FROM "users" WHERE "users"."id" = $1
我通过添加
has\u many:recherches,dependent::destroy
修复了此问题,但现在我遇到以下错误:

NameError in Admin::Users#index


Showing /home/charles/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/activeadmin-0a5a15b88bff/app/views/active_admin/resource/index.html.arb where line #2 raised:

uninitialized constant User::Recherch

这两个错误都与类Recherche有关,但我找不到问题的根源。是控制器吗?模型?还有什么吗?

根据您的信息,由于以下代码:

has_many :recherches, dependent: :destroy
…Rails正试图将复数形式的“recherches”转换为单数形式的“recherch”,而不是您的类名称——“Recherche”。在这种情况下,您必须覆盖Rails的命名约定:

# config/initializers/inflections.rb

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'recherche', 'recherches'
end

你能在这里更新你的两个型号代码吗?