How to enable multi-line content in rails text_area field?

How can I allow users to enter multi-line text in the text_area form text_area ?

Currently, the content content is entered in the text area , line breaks are deleted ... They are saved when editing the content ... So, maybe in the view to show that the breaks are deleted?

I found a few things that indicate that I will need to implement the WYSIWYG editor, but I would rather avoid this if possible.

Any suggestions?

UPDATE: So, it looks like the rails store the content with line breaks, and I can add .html_safe to the field in the show view (i.e. <%= @post.post.html_safe %> ). Now it will contain content with basic html (for example, <br> , <b> , etc.), but still does not display line breaks in the content (i.e. when I press the enter button for a new line), which rails are saved, and I can view when I edit the content.

+8
ruby-on-rails
source share
1 answer

Linear lines are not displayed in HTML. You will want to use something like simple_format or wraptext in your content to convert newlines to <br> or <p> tags.

 <%=simple_format(@post.post).html_safe %> 

or

 <%=Wraptext::Parser.new(@post.post).to_html.html_safe %> 
+11
source share

All Articles