Files
nairobi/app/components/admin/action_component.html.erb
Javi Martín aaa5f6c285 Disable buttons in table actions when pressed
By default, Rails disables submit inputs (<input type="submit">) when
they're pressed so we avoid a double-submission when users click the
button twice.

However, Rails does not disable submit buttons (<button type="submit">)
when they're pressed. This means there's a chance users might press the
button several times. Even if most our table actions are idempotent, it
might cause certain issues. For instance, pressing the "Delete" button
twice means the second request might raise an
`ActiveRecord::RecordNotFound` exception.

Disabling the button also gives feedback to users, letting them know
they've correctly clicked the button.
2021-09-20 20:27:37 +02:00

6 lines
128 B
Plaintext

<% if button? %>
<%= button_to(path, html_options) { text } %>
<% else %>
<%= link_to text, path, html_options %>
<% end %>