5
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Rails】Twitterシェアボタンの作成方法

Posted at

目標

ezgif.com-video-to-gif.gif

開発環境

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

前提

下記実装済み。

Slim導入
Bootstrap3導入
Font Awesome導入

実装

books/show.html.slim
= link_to "https://twitter.com/share?url=#{ request.url }&text=#{ @book.title }を、Twitterでみんなに広めよう!", class: 'btn btn-default', target: '_blank' do
  i.fab.fa-twitter style='color: #3399FF;'
  |  Twitterでシェア

url=#{ request.url }
➡︎ ツイート内に該当ページのURLを埋め込む。

&text=#
➡︎ ツイート内容を作成する。

5
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?