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,html]文字省略〜続きを読む実装〜

Posted at

簡単なブログサイトを作成中に、よくサイトで記事が一定の文字数を超えた時に「...続きを見る」を実装したかったので調べて実装してみた。

##コード

<%= truncate(45, omission: "") %>

45文字以上は切り捨て。omissionは切り捨てた場合に表示させたい文字を書く。

続きを読む.png

無事45文字で切れた!!!

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?