0
0

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】link_toでhtmlタグを使う

Posted at

はじめに

ポートフォリオ作成中にhtmlタグをlink_toに入れる方法がわからなかった為、備忘録として記録。

使い方

link_toの記載は変更前の記述で書いてましたが、このままだとクラス追加しか出来なかったので変更後のブロック構造に変更。

変更前

<%= link_to "文字列", パス %>

変更後

<%= link_to パス do %>
 htmlタグ、文字列
<% end %>

以下、記述例

<%= link_to new_portfolio_path do %>
  <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
  Add
<% end %>
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?