LoginSignup
0
0

More than 1 year has passed since last update.

[Ruby on rails] 改行の反映 form_withで入力

Posted at

やりたいこと

改行も反映させたい!!!!!

現状

form-withで改行して入力しても、
反映されない!

スクリーンショット 2021-07-31 21.16.17.png
スクリーンショット 2021-07-31 21.16.58.png

<div class="form-group">
        <%= f.label :introduction,"自己紹介" %><br />
        <%= f.text_area :introduction, autofocus: true,class:"form-control" %>
</div>
<div class="col-md-8 ml-5" style="margin-top:1em;">
  <h6>Introduction</h6>
  <p><%= user.introduction %></p>
</div>

改善後

スクリーンショット 2021-07-31 21.21.57.png

こう書くと、改行される!!!

safe_joinの部分です。

<div class="col-md-8 ml-5" style="margin-top:1em;">
  <h6>Introduction</h6>
  <p><%=safe_join(user.introduction.split("\n"),tag(:br)) %></p>
</div>
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0