Home > Net >  ActiveAdmin taking wrong http method for update and destroy actions
ActiveAdmin taking wrong http method for update and destroy actions

Time:10-29

Rails version - 5.2
Active admin version - 2.9.0

I have installed and configured active admin in my rails API application. Everything is working fine, except for the update, delete action of any controller, and logout of the admin user.

Here is my applicaiton.rb file

enter image description here

I have added method override in application.rb file though it is taking the POST request method for any update or delete request. It is working fine in my local even though it is taking POST request but when I deployed the code on the staging environment. I have found this thing. On my staging environment, that route is not present hence it is giving 404 error.

Below is the screenshot of the Update admin user request.

enter image description here

Can someone please help me to fix this issue?

CodePudding user response:

I have finally fixed the issue. I am assuming the issue might be with my staging web server configuration otherwise it was working fine in my local in both the environments local and staging.

Post the answer here so it might help people in future.

By default the browser only supports for GET and POST requests. If we want to use any other request methods then we need to pass that request method in the parameter _method. You can read more about it here.

That wasn't happening in my case though i have added config.middleware.use Rack::MethodOverride in application.rb.

For resolving the issue, I have added the use Rack::MethodOverride in my config.ru file. It means before running the rails application it will use this method. I have added this code and that's it everything is working fine now.

  • Related