I'm just following some rails tutorials, and built a basic CRUD app (a blog with comment system). My problem is that when I loop through each comment for a post, an annoying dump of the records is displayed after the each loop. It looks like there is some inspect dump, but I can't find the reason for this. Here is the code for the loop:
<h3>Comments</h3>
<%= @post.comments.each do |comment| %>
<div class="well">
<p><strong><%= comment.username %></strong>: <%= comment.body %></p>
</div>
<%= link_to "[X]", [comment.post, comment], method: :delete, data: {confirm: 'Are you sure?'}, :class => 'btn btn-danger' %>
<hr>
<% end %>
Here is also the comment controller:
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(comment_params)
redirect_to post_path(@post)
end
private def comment_params
params.require(:comment).permit(:username, :body)
end
def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
end
end
And here is a screenshot:
Many thanks in advance for your help