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) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With