Conservar nueva línea en el área de texto con Ruby on Rails
Para practicar Ruby on Rails, estoy creando un blog que incluye un área de texto (siguiendo el tutorial de Mackenzie Child). Cuando se envía el texto, se eliminan todas las líneas nuevas. Sé que ya se han hecho variaciones de la pregunta, pero no he podido replicar ninguno de los resultados a pesar de haberlo intentado todo un día. No estoy muy familiarizado con JQuery.
¿Existe un conjunto de pasos que preservarán las nuevas líneas?
_form.html.erb
<div class="form">
<%= form_for @post do |f| %>
<%= f.label :title %><br>
<%= f.text_field :title %><br>
<br>
<%= f.label :body %><br>
<%= f.text_area :body %><br>
<br>
<%= f.submit %>
<% end %>
</div>
posts_controller.rb
class PostsController < ApplicationController before_action :authenticate_user!, except: [:index, :show]
def index
@posts = Post.all.order('created_at DESC')
end
def new
@post = Post.new
end
def create
@post = Post.new(post_params)
@post.save
redirect_to @post
end
def show
@post = Post.find(params[:id])
end
def edit
@post = Post.find(params[:id])
end
def update
@post = Post.find(params[:id])
if @post.update(params[:post].permit(:title, :body))
redirect_to @post
else
render 'edit'
end
end
def destroy
@post = Post.find(params[:id])
@post.destroy
redirect_to posts_path
end
private
def post_params
params.require(:post).permit(:title, :body)
end
end