Help us understand the problem. What is going on with this article?

rails APIモード+ActiveAdminで、管理者画面にてユーザーを削除しようとしたらNo route matchesのエラーが発生した際の対処法

環境

  • Rails 5.2.3 (APIモード)
  • activeadmin (2.3.1)

事象

管理者画面(http://localhost:3000/admin/) にて、管理者を削除するボタンを押したところ、Routing Error No route matches [POST] "/admin/admin_users/2"が発生する。

原因

HTTPのPUTメソッド、DELETEメソッドを実現するためのミドルウェアであるRack::MethodOverrideが使用されていなかったため。

対応

  1. rake middlewareコマンドを実行し、Rack::MethodOverrideがないことを確認
  2. application.rbにconfig.middleware.use Rack::MethodOverrideを追加
class Application < Rails::Application
  (中略)
   config.middleware.use Rack::MethodOverride

参考

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away