ruby on rails - Partial rendering one time too many for collection -
creating simple blog application,
i have partial
.comment %p %b namn: = comment.name %p %b kommentar: = comment.content %p = link_to 'destroy comment', [comment.post, comment], :confirm => 'are sure?', :method => :delete
and called from
= render :partial => 'comment', :collection => @post.comments
it renders partial 1 time many?
edit:
it has form
= form_for ([@post,@post.comments.build])
as depicted in comments of question, @post.comments.build
culprit. change to
= form_for ([@post, @post.comments.new])
and additional item when rendering collection should gone.
there post difference of build , new here: build vs new in rails 3
Comments
Post a Comment