New Discussion

Notifications

You’re not receiving notifications from this thread.

The difference between Link_to vs Button_to in Ruby on Rails Discussion

0
General

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
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.