I have started the "Get Started Guide" from the ruby on rails website. Everything works fine, but when I change the order of showing all comments and than display the comments-form in the other way round, than the form_forfunction adds a empty comments model to @post.comments and so, I display one empty comment in the loop.
Here is the view:
<h1><%= @post.name %></h1>
<p><%= @post.text %></p>
<h2>Add comment</h2>
<%= form_for([@post, @post.comments.build]) do |f| %>
<p>
<%= f.label :name %><br>
<%= f.text_field :name %>
</p>
<p>
<%= f.label :email %><br>
<%= f.text_field :email %>
</p>
<p>
<%= f.label :text %><br>
<%= f.text_area :text %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
<h2>Comments</h2>
<%= render @post.comments %>
The loop display two comments. One, that exists in the db and one, that has just empty attributes. If I delete the form, than all is shown up correct.