pra*_*ski 2 ruby-on-rails ruby-on-rails-3
我有一个text_area标签,允许用户输入他的生物.当用户敲打并且如果他命中输入或返回时,则开始换行.但是当他保存输入时,所有文本都显示在一个段落中.我想要的功能类似于堆栈溢出.
例如 - 我现在点击进入
此文字出现在新行*
我怎样才能做到这一点?
This is my code in Rails:
<%= form_for :profile do |profile| %>
<%= profile.text_area :bio %>
<%= f.submit "Save Bio" %></p>
<% end %>
Run Code Online (Sandbox Code Playgroud)
您应该使用文本编辑器例如ckeditor(以简化Web内容创建),并在视图中尝试simpleformat或raw:
<%= simple_format("Here is some basic text...\n...with a line break.") %>
<%= raw("Here is some basic text...<br/>...with a line break.") %>
Run Code Online (Sandbox Code Playgroud)