Implement button transitions using link_to in Rails

Overview

What I want to implement this time is an implementation that gives a link to a button like the image below with the link_to method.

syuppinn.png

By clicking this'List'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 don't know why link_to is better ...

・ Description in a href element

ruby:xxx.html.erb


<a href="path">
Description of listing images and text
</a>

・ Description with link_to

ruby:xxx.html.erb


<%= link_to("URL") do %>
Write the HTML code here
<% end %>

Example

The code written in this implementation is pasted as a reference example.

ruby:xxx.html.erb


<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>

Recommended Posts

Implement button transitions using link_to in Rails
Implement markdown in Rails
Implement star rating function using Raty in Rails6
Implement application function in Rails
Implement follow function in Rails
Japaneseize using i18n with Rails
Implement import process in Rails
Implement simple login function in Rails
Implement CSV download function in Rails
How to implement ranking functionality in Rails
How to implement image posting using rails
Create authentication function in Rails application using devise
[Rails] Run LINEBot in local environment using ngrok
[Rails6 + Vue.js] Implement CSV import process using axios
How to implement image posting function using Active Storage in Ruby on Rails
Implement Rails pagination
Group_by in Rails
How to implement a like feature in Rails
[Rails] Show avatars in posts using Active Storage
Implement the Like feature in Ajax with Rails.
Implement iteration in View by rendering collection [Rails]
How to implement a circular profile image in Rails using CarrierWave and R Magick
How to implement guest login in 5 minutes in rails portfolio
Implement post search function in Rails application (where method)
How to implement a like feature in Ajax in Rails
Introduce devise in Rails to implement user management functionality
Implement test doubles in JUnit without using external libraries
Implement user follow function in Rails (I use Ajax) ①
Rails learning How to implement search function using ActiveModel
Try to implement tagging function using rails and js
Implement ProgressBar using library
Model association in Rails
Adding columns in Rails
[Rails] Implement search function
Disable turbolinks in Rails
Implement Rails account BAN
^, $ in Rails regular expression
Use images in Rails
Implement CustomView in code
Understand migration in rails
Split routes.rb in Rails6
[Rails] Implement rake task
Succeeded in loading js manually compiled using webpack with rails6
Implement login function in Rails simply by name and password (1)
Implement login function in Rails simply by name and password (2)
Display API definition in Swagger UI using Docker + Rails6 + apipie
[Rails] I tried to implement "Like function" using rails and js
Implement user registration function and corporate registration function separately in Rails devise
[Rails] Implement community membership application / approval function using many-to-many associations