Home > Software engineering >  How to make a delete button in rails without embedded ruby
How to make a delete button in rails without embedded ruby

Time:09-30

I have two buttons which I want to put next to each other in embedded ruby. Per this post, I have opted to use HTML over embedded ruby to make these buttons. My delete button looks like this:

<a href="<%= @post %>", ><button>Delete</button></a>

In embedded Ruby, the equivilet would look like:

<%= button_to "Delete", @post, method: :delete, class:"btn btn-danger"%>

Is there a way to add <% method: :delete %> to my HTML button in order to make it work?

CodePudding user response:

If I understood you right, that you need put these buttons side-by-side to each other. I see you use bootstrap you can do it in next way: Use bootstrap class 'inner-flex' for div and put there all yours buttons for horizontal outpputing

<div >
  <%= link_to "Edit", edit_post_path(@post), class:"buttons btn btn-warning"%>
  <%= button_to "Delete", @post, method: :delete, class:"btn btn-danger" %>
</div>
  • Related