Forum: Ruby on Rails substring and html in the db

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E2489efc6ec10ec818b71965909ea109?d=identicon&s=25 Jin Lee (Guest)
on 2006-03-29 01:26
(Received via mailing list)
Hey guys,

Ran into a snag today and was wondering if anyone can give me a hand. I
have
a blog type application that I'm developing. There is a page "list all
entries" which looks like this:

Title1
posted by Person1 about 2 hours ago
test1 test1test1 test1test1 test1test1 test1test1 test1test1 test1test1
test1... (click here for full post)

Title2
posted by Person1 about 2 hours ago
test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1
test1 test1...(click here for full post)

I "preview" the news entries by displaying the first 200 characters of
the
body of each entry, with a ...(click here for full post)
The problem is when I introduce HTML code into the body. If for example,
I
am in the middle of a hyperlink < a > tag when cutting off at the 200th
character, the HTML breaks the whole page.

Options: write some type of UBB thing, not allowing html and instead
stuff
like [link] and [img]

My question is, has anyone tackled this? DRY is the name of the game =)
Thank you very much,
Jin
This topic is locked and can not be replied to.