Limiting characters/words in view - ruby on rails

前端 未结 4 2009
情深已故
情深已故 2021-02-03 20:43

I am displaying recent comments on the home page of a very simple blog application I am building in Ruby on Rails. I want to limit the number of characters that are displayed fr

4条回答
  •  余生分开走
    2021-02-03 21:40

    You can also use the truncate method if you want to limit the number of characters. I'm using this to display just enough characters in a bootstrap row to somewhat match the height of an image displayed in the same row.

    <%= "#{message.truncate(charcount)}" %>
    

提交回复
热议问题