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.
6 lines
128 B
Plaintext
6 lines
128 B
Plaintext
<% if button? %>
|
|
<%= button_to(path, html_options) { text } %>
|
|
<% else %>
|
|
<%= link_to text, path, html_options %>
|
|
<% end %>
|