truncate text at a word boundry
1 # in application_helper 2 3 def snippet(text, wordcount, omission) 4 text.split[0..(wordcount-1)].join(" ") + (text.split.size > wordcount ? " " + omission : "") 5 end 6 7 8 # example 9 10 snippet(@post.body, 50, "#{link_to "More...", @post}")