Creating a simple blog application,
I have this partial
.comment %p %b Namn: = comment.name %p %b kommentar: = comment.content %p = link_to 'Destroy Comment', [comment.post, comment], :confirm => 'Are you sure?', :method => :delete
and its called from
= render :partial => 'comment', :collection => @post.comments
it always renders the partial one time to many?
It has this form
= form_for ([@post,@post.comments.build])Answer1:
As depicted in the comments of your question, the
@post.comments.build is the culprit. Change it to
= form_for ([@post, @post.comments.new])
and the additional item when rendering the collection should be gone.
There is a good post about the difference of build and new here: <a href="https://stackoverflow.com/questions/4954313/build-vs-new-in-rails-3" rel="nofollow">Build vs new in Rails 3</a>