I am using CKEditor for my blogging app, and am saving formatting data in my :content attribute.
For example, a particular @post.content may start out like this.
<p>\r\n\t<span class=\"s1\" style=\"color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1.1em; line-height: 1.7em;\">This is my text starting here. This is an really awesome entry, you see...
The first part of the entry is all formatting data, and the actual written content starts with “This is my text starting here…”
What I would like to do is display the first fifty characters of the written content.
I tried something like this,
<%= post.content.first(50).try(:html_safe) %>
But this doesn’t return anything, unless the formatting data is less than fifty characters.
How can I go about displaying the first fifty characters of written content?
Please let me know if this is unclear, or if any additional info is needed. Thanks much for your help!
try using strip_tags method
e.g.