I'm new to programming and have been learning Ruby on Rails for about 6 weeks. I've added commenting functionality to my app, and while comments are being displayed properly, so is everything else in the (sqlite3) database associated with the comment - created_at, updated_at, comment_id, post_id. The partial that displays comments has the following code:
<%= form_for [post, comment] do |f| %>
<p><%= @comments.each do |comment| %></p>
<small>
<p><%= comment.body %></p>
</small>
<% end %>
<% end %>
As you can see, I'm only trying to display the comment body, but I'm displaying everything.
Here is the create method from the comments controller:
def create
@post = Post.find(params[:post_id])
@comment = current_user.comments.build(params_comment)
@comment.post = @post
authorize @comment
if @comment.save
flash[:notice] = "Comment was created"
redirect_to [@post.topic, @post]
else
flash[:error] = "Comment failed to save"
redirect_to [@post.topic, @post]
end
end
end
I'm not sure why everyting is displaying if I'm only calling .body on comment. I've researched this problem but haven't found anything. Any help would be appreciated.