Rails truncate helper with link as omit text

前端 未结 7 1895
忘掉有多难
忘掉有多难 2021-02-06 01:27

I\'m quite long description that I want to truncate using truncate helper. So i\'m using the:

truncate article.description, :length => 200, :omission => \         


        
7条回答
  •  臣服心动
    2021-02-06 01:47

    The only one that worked for me :

    <%= truncate(@article.content, length: 200, omission: " ... %s") % link_to('read more', article_path(@article)) %>
    

提交回复
热议问题