Add HTML formatting to text_fields

12 views
Skip to first unread message

Colin Stodd

unread,
Aug 15, 2014, 10:05:17 AM8/15/14
to rubyonra...@googlegroups.com
Hey guys, another newb here :)  Anyway, I'm building another social network, and I would like to be able to have users type in some text in the "Comment" area, and when they put a "new line" space to make a new paragraph, have it show up when its posted to the site.

1.  Is there a way for them to do it without having to add a <br /> tag.  Have it happen similarly to how this google group post is line-breaking?

if not

2.  Is there a way to make the text_field respond to HTML formatting?

Thanks in advance for your help!

Dave Aronson

unread,
Aug 15, 2014, 10:12:18 AM8/15/14
to rubyonrails-talk
On Fri, Aug 15, 2014 at 10:05 AM, Colin Stodd <cbs...@gmail.com> wrote:

> I would like to be able to have users type in some text in the "Comment"
> area, and when they put a "new line" space to make a new paragraph, have it
> show up when its posted to the site.

Check out simple_format. It preserves linebreaks, URLs, and some
other simple HTML, but (if I remember correctly) filters out a lot of
dangerous junk (like script tags). There are also some gems available
to add a WYSIWYG editor.

-Dave

--
Dave Aronson, freelance software developer (details @ www.Codosaur.us);
see also www.PullRequestRoulette.com, Blog.Codosaur.us, www.Dare2XL.com
Reply all
Reply to author
Forward
0 new messages