ActiveAdmin “Delete” link redirects to show instead of deleting on Rails 8 (Turbo / importmap / propshaft)

1 week ago 11
ARTICLE AD BOX

I'm using Rails 8.0.3 with importmap + propshaft + turbo-rails and ActiveAdmin.

In ActiveAdmin index, the "Remove" link redirects to the show page instead of deleting the record. It looks like the link is doing a GET instead of a DELETE.

## Expected behavior

Click "Remove" -> confirmation -> record is destroyed -> redirect back to index.

## Actual behavior

Click "Remove" -> goes to `/admin/students/:id` (show) and nothing is deleted.

## Link HTML generated by ActiveAdmin

html <a class="delete_link member_link" title="Remover" data-confirm="Você tem certeza que deseja remover este item?" rel="nofollow" data-method="delete" href="/admin/students/1305">Remover</a> #app/javascript/application.js import "@hotwired/turbo-rails" import "controllers" import Rails from "@rails/ujs" Rails.start() # app/views/layouts/active_admin.html.erb <!DOCTYPE html> <html> <head> <title>Admin</title> <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag "active_admin", "data-turbo-track": "reload" %> <%= javascript_importmap_tags %> </head> <body class="active_admin"> <%= yield %> </body> </html> ActiveAdmin.register Student do permit_params :name, :phone, :email, :active index do selectable_column id_column column :name column :email column :phone column :active actions end end

What I've tried

Starting @rails/ujs in application.js (shown above).

Custom JS to convert data-method to data-turbo-method (didn't work).

Using button_to ... method: :delete in the index (also didn't work; still seems to behave like GET).

Question

What is the correct way to make ActiveAdmin destroy links work on Rails 8 with Turbo/importmap/propshaft?
Is ActiveAdmin relying on rails-ujs (data-method), and if so, how should it be loaded/initialized in Rails 8 admin pages?

Read Entire Article