On 12 Jun 2009, at 12:11, Petan Cert wrote:

> I am wondering if there is some kind of built in function to strip the
> text to given length, but I dont want to cut the word in the  
> middle. :)
>
> I know that this works, but it cuts the text.
> <%= @post.body[0..60] %>
>
> Is there a way to do the same thing but keep the last word as it is or
> if the length of the word is longer than given size, strip the whole
> word, not just the part of it.

http://vermicel.li/blog/2009/01/30/awesome-truncation-in-rails.html


Best regards

Peter De Berdt


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to