Ask A Question


You’re not receiving notifications from this thread.

The difference between Link_to vs Button_to in Ruby on Rails Discussion

Another trick is to use formaction for having multiple buttons in the same form without using any hidden forms.

For example:

<%= form_with model: @blog_post do [form| %> 
  <%= form. submit "Save" %>
  <%= tag.button "Publish", formaction: publish_blog_post_path(@blog_post) %>
<% end %>
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 74,071+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.