HTML stripping, Truncating string in Ruby, Rails
For Truncating String I have used 'truncate' rails helper method.
limiting to 10 characters
limiting to 10 characters
truncate("im srikanth glad to meet you", 10)
>> "im srik..."
For HTML stripping, I have used gsub..
>> "im srik..."
str.gsub(/<\/?[^>]*>/, "")
Comments
<%= truncate(strip_tags(product.description), :length => 80) %>
By the way you can use SyntaxHighlighter to make the code from your blogspot pretty. http://alexgorbatchev.com/SyntaxHighlighter/
<%= truncate(strip_tags(product.description), :length => 80) %>