Reputation: 4480
I have a loop for comments that I want to print in a text_area_tag. Here is my code
<%=text_area_tag 'body', nil, rows: 10, cols: 25%>
<% @comments.each do |comment|%>
<p><%=comment.user_name%> says: <%=comment.comment%></p>
<%end%>
What I am trying to do is, instead of printing out all the comments in the p tags, I want to print them inside the text_area_tag
Upvotes: 0
Views: 78
Reputation: 136
You can use the Rails helpers like simple_format
<% @comments.each do |comment| %>
<p><%=comment.user_name%> says: <%= simple_format comment.comment %></p>
<% end %>
Other helpers you may be wanting to experiment with: (text = comment.comment)
<%= raw text %>
<%= h text %>
<%= text.html_safe %>
Upvotes: 1