[RUBY] [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
[Rails] How to create a signed URL for CloudFront
[Java] How to create a folder
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
How to create a database for H2 Database anywhere
How to write Rails
[Rails] rails new to create a database with PostgreSQL
How to create a query using variables in GraphQL [Using Ruby on Rails]
[swift5] How to implement the Twitter share function
How to create a class that inherits class information
How to create a theme in Liferay 7 / DXP
How to uninstall Rails
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
[1st] How to create a Spring-MVC framework project
How to create docker-compose
Rails6.0 ~ How to create an eco-friendly development environment
[Rails] How to create a table, add a column, and change the column type
How to make a follow function in Rails
[Introduction] Try to create a Ruby on Rails application
How to create a Java environment in just 3 seconds
How to implement a like feature in Ajax in Rails
How to delete a new_record object built with Rails
How to create a JDBC URL (Oracle Database, Thin)
[Spring Boot] How to create a project (for beginners)
How to manually generate a JWT with Rails Knock
[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
How to get started with creating a Rails app
[Apple Subscription Offer] How to create a promotional offer signature
[Rails] How to install a decorator using gem draper
How to create an application
[rails] How to post images
[Rails] How to use enum
[Rails] How to install devise
[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 validation
How to write Rails seed
[Rails] How to use validation
[Rails] How to disable turbolinks
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[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