Default to delete method for the destroy action

This is consistent with what Rails does.
This commit is contained in:
Javi Martín
2024-03-06 15:07:14 +01:00
parent 54977116e7
commit 251a5fb6e9
12 changed files with 42 additions and 14 deletions

View File

@@ -11,7 +11,11 @@ class Admin::ActionComponent < ApplicationComponent
private
def button?
options[:method] && options[:method] != :get
method && method != :get
end
def method
options[:method] || (:delete if action == :destroy)
end
def text
@@ -30,6 +34,7 @@ class Admin::ActionComponent < ApplicationComponent
def html_options
{
method: method,
class: html_class,
id: (dom_id(record, action) if record.respond_to?(:to_key)),
"aria-describedby": describedby,
@@ -38,7 +43,7 @@ class Admin::ActionComponent < ApplicationComponent
confirm: confirmation_text,
disable_with: (text if button?)
}
}.merge(options.except(:"aria-describedby", :"aria-label", :class, :confirm, :path, :text))
}.merge(options.except(:"aria-describedby", :"aria-label", :class, :confirm, :method, :path, :text))
end
def html_class