Reputation: 6209
I'm using ActiveAdmin (master) on Rails 4.2 with rails-api. I've done all the proper configuration so that AA works properly. I can use index pages, show, use the edit form, etc. But when it comes time to take a destructive action, for some reason AA uses POST instead of the proper http verb. The result is a 404:
No route matches [POST] "/admin/admin_users/1"
When I copy the request as a cURL via the chrome console, modify the HTTP method from POST to DELETE, everything works properly and the user is deleted. So why is ActiveAdmin using POST?
Upvotes: 1
Views: 902
Reputation: 1101
I had this same issue, using activeadmin 1.0.0 and Rails 5.0.2. The form has the correct html, but the controller was receiving a POST:
<input type="hidden" name="_method" value="patch">
I checked, the Rack::MethodOverride
middleware was in place.
My issue was fixed by correcting the permit_params: https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters.
I do not understand how that affects the POST/PATCH, but it did.
Upvotes: 0
Reputation: 6209
I needed to add the Rack::MethodOverride
to my middleware stack (you can confirm it's missing by running rake middleware
).
Add it like so:
# config/application.rb
module MyApi
class Application < Rails::Application
config.middleware.use Rack::MethodOverride
end
end
Upvotes: 3