简体   繁体   中英

Ruby on Rails - how to input line breaks into textarea so when the content is displayed, line breaks are also there?

I am the admin of a site, and I have a special textarea that only I populate (ie I am not concerned about someone trying to mess with it to wreck my site). I want to put some line breaks when I input in this textarea, so that when it is displayed there are some decent line breaks.

How do I go about this?

Use the simple_format helper in rails.
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html

It will interpret line breaks and insert the correct HTML so that the text is displayed correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM