I have anchor links in rails like this.
<%= link_to 'Edit', edit_product_path(@product) %> |
<%= link_to 'Back', products_path %>
I want to have them as a button and I want to use bootstrap button.
Here's how I am trying to achieve it.
<div class="btn btn-primary">
<%= link_to 'Edit', edit_product_path(@product) :class => "btn" %> |
<%= link_to 'Back', products_path :class => "btn"%>
</div>
But this is not working for some reason.
What's wrong here?
You forgot the comma after the path:
<div class="btn btn-primary">
<%= link_to 'Edit', edit_product_path(@product), :class => "btn" %> |
<%= link_to 'Back', products_path, :class => "btn"%>
</div>
Other than the comma is missing, it would be better to remove or modify the class attribute in the div tag to something more sensible it as this would create an unnecessary duplicate of buttons inside one another. It should look something like this:
<div>
<%= link_to 'Edit', edit_product_path(@product), :class => "btn btn-primary" %> |
<%= link_to 'Back', products_path, :class => "btn"%>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With