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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -