[Rails] How to create a Twitter share button



Development environment

・ Ruby: 2.5.7 Rails: 5.2.4 ・ Vagrant: 2.2.7 -VirtualBox: 6.1 ・ OS: macOS Catalina


The following has been implemented.

Slim introductionIntroduction of Bootstrap3Introduction of Font Awesome



= link_to "https://twitter.com/share?url=#{ request.url }&text=#{ @book.title }Let's spread to everyone on Twitter!", class: 'btn btn-default', target: '_blank' do
  i.fab.fa-twitter style='color: #3399FF;'
  |Share on Twitter

url=#{ request.url } ➡︎ Embed the URL of the corresponding page in the tweet.

&text=# ➡︎ Create tweet content.

Recommended Posts

[Rails] How to create a Twitter share button
[rails] How to create a partial template
[Rails] How to create a graph using lazy_high_charts
How to easily create a pull-down in Rails
How to create a method
Preparing to create a Rails application
How to insert a video in Rails
How to create a Maven repository for 2020
[Swift5] How to create a splash screen
[Rails 6] How to create a dynamic form input screen using cocoon
Rails: How to write a rake task nicely
How to create a database for H2 Database anywhere
[Rails] How to write when making a subquery
[Rails] rails new to create a database with PostgreSQL
How to create a query using variables in GraphQL [Using Ruby on Rails]
How to create pagination for a "kaminari" array
How to create a class that inherits class information
How to create a theme in Liferay 7 / DXP
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
[1st] How to create a Spring-MVC framework project
How to implement a like feature in Rails
Rails6.0 ~ How to create an eco-friendly development environment
[Rails] How to create a table, add a column, and change the column type
[Introduction] Try to create a Ruby on Rails application
How to create a Java environment in just 3 seconds
How to delete a new_record object built with Rails
How to create a JDBC URL (Oracle Database, Thin)
How to create a Spring Boot project in IntelliJ
[Spring Boot] How to create a project (for beginners)
How to manually generate a JWT with Rails Knock
How to create a data URI (base64) in Java
[How to insert a video in haml with Rails]
How to write a date comparison search in Rails
[Rails 6] How to set a background image in Rails [CSS]
[Rails] How to load JavaScript in a specific view
(Ruby on Rails6) How to create models and tables
[Apple Subscription Offer] How to create a promotional offer signature
[rails] How to post images
[Rails] How to use enum
[Rails] How to use enum
How to leave a comment
How to read rails routes
How to use rails join
How to terminate rails server
How to write Rails seed
[Rails] How to use validation
[Rails] How to disable turbolinks
[Rails] How to use authenticate_user!
[Rails] How to implement scraping
[Rails] How to make seed
How to write Rails routing
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
How to insert a video
[Rails] How to use Scope
Tutorial to create a blog with Rails for beginners Part 1
How to create a lightweight container image for Java apps
How to create a form to select a date from the calendar
How to create a placeholder part to use in the IN clause
I want to create a form to select the [Rails] category
A series of steps to create portfolio deliverables with Rails