Want more GoRails?
GoRails is packed full with 725 lessons just like this one.
Sign up to get full access or log in to your account and sit back.
Your Teacher
Chris Oliver
Hi, I'm Chris. I'm the creator of GoRails, Hatchbox.io and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.
About This Episode
HTML provides some handy attributes for buttons to target specific forms on the page. Learn how to use them to improve your Rails application forms.
Notes
<%= form_with model: product do |form| %>
<%# rest of the form ... %>
<div>
<%= form.submit %>
<%= button_tag "Delete", form: :delete_product %>
</div>
<% end %>
<%= form_with model: @product, method: :delete, id: :delete_product, data: { turbo_confirm: "Are you sure?" } do %>
<% end %