Reputation: 31
Why this code is not work?
<%= truncate(post.text, :length => post.text.rindex(".", 500)) %>
I need to trim the text on last dot before 500th symbol.
Upvotes: 0
Views: 767
Reputation: 845
Use the :separator
option. It will truncate at the dot before 500 characters
truncate(post.text, :length => 500, :separator => '.')
Upvotes: 3