From: "Jean-Sébastien D." Date: 2012-08-30T22:12:04+09:00 Subject: Re: String in rails and ruby show first n character Lars Haugseth wrote in post #1073861: > On 08/29/2012 08:34 PM, Bartosz Dziewoński wrote: >> Use String#[]: http://www.ruby-doc.org/core-1.9.3/String.html#method-i-5B-5D >> >> <%= f.description[0, 200] %> > > In Rails, you can also utilize the truncate helper method: > > <%= truncate(f.description, :length => 200, :separator => ' ') %> > > This will ensure the string is not chopped off in the middle of a word. > > http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-truncate Thanks both works, didn't know about both of them -- Posted via http://www.ruby-forum.com/.