How do I get only first (say) 200 characters from my object Article (which is in a table articles with aattributes content and title)?
Thank you
The rails' TextHelper has a truncate method.
So, in your views, you just have to do :
<%= truncate @article.content, :length => 50 %>
Where 50 is the number of characters you want to display.
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