RoR trim string
this gives
开发者_运维技巧abcdefghi
but I want it to be
if length is greater than 5 then
abcde...
if less than 5 then
abcde
Rails has a built-in view helper for this:
<%= truncate(user.name, :length => 5) %>
- truncate helper API documentation
精彩评论