LoginSignup
1
0

More than 1 year has passed since last update.

【Rails】link_to で「ブラウザ上に表示する文字列」と「指定するURL」が同一のときは nil を使う。

Posted at

はじめに

未経験からエンジニアに転職しました。
まだまだわからないことだらけですが、毎日楽しく働いています!
業務や個人開発での発見やエラー解決などをアウトプットしています。
今回は、

link_to で「ブラウザ上に表示する文字列」と「指定するURL」が同一のときは nil を使う。

という内容です。
初学者向けの内容です。

結論

<%= link_to nil, 'https://qiita.com/' %>

上記のように書く。
下記と同じ結果になる。

<%= link_to 'https://qiita.com/', 'https://qiita.com/' %>

参考

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