1
2

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 5 years have passed since last update.

truncateメソッドの使い方

Last updated at Posted at 2015-04-29
truncate.html.erb
<% msg = '<strong>Rails</strong>はRubyベースのフレームワークです。Railsに影響を受けたフレームワークには、Catalystやsymdonyなどがあります、' %>

<%= truncate(msg, length: 50) %>
<%= truncate(msg, length: 50, separator: '。') %>
<%= truncate(msg, length: 50, omission: '・・・後略・・・') %>
code

(『Ruby on Rails4アプリケーション・プログラム』より抜粋)

「truncate」自体は、翻訳すると
1.頭や端を切る
2.(引用文などを)を切り縮める

注意事項→間違っても<%== %>で出力しないようにすること。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?