Reputation: 1121
this gives
abcdefghi
but I want it to be
if length is greater than 5 then
abcde...
if less than 5 then
abcde
Upvotes: 2
Views: 1945
Reputation: 115322
Rails has a built-in view helper for this:
<%= truncate(user.name, :length => 5) %>
Upvotes: 9