What I want to implement this time is an implementation that gives a link to the button like the image below with the link_to method.
By clicking this’Sell’ button, you can move to the link of the given product posting page.
There are two ways
There are two ways to implement this feature. I’m not sure why link_to is better…
- Description with a href element
<a href="path"> Description of the listing image or text </a>
・Description in link_to
<%= link_to("URL") do %> Write the HTML code here <% end %>
The code described in this implementation is pasted as a reference example.
<div class='purchase-btn'> <span class='purchase-btn-text'>Sell</span> <%= link_to ("/products/new") do %> <%= image_tag'camera.png' ,size: '185x50' ,class: "purchase-btn-icon" %> <% end %> </div>