Forum: Ruby on Rails Add HTML formatting to text_fields

B5811ff5bb3b559d7c0f77ddbf407e3c?d=identicon&s=25 Colin Mr. (cbstodd)
on 2014-08-15 16:06
(Received via mailing list)
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!
Ec2c1a36301b0223c3e281bd2ec3f37a?d=identicon&s=25 Dave Aronson (Guest)
on 2014-08-15 16:13
(Received via mailing list)
On Fri, Aug 15, 2014 at 10:05 AM, Colin Stodd <cbstodd@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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.