On Apr 20, 12:46 pm, Neil Bye <li...@ruby-forum.com> wrote: > > def create > @comment = Comment.find(params[:id]) > @comment.subcomments.create( :comment_id => @comment.id , :body => > params[:subcomment][:body]) > render :update do |page| > page.reload > end > end > > _comment.html.erb has > > <% @user.comments.each do |comment| %> > <div id="remark"<p><%= comment.body %></p> > <div id="commenter"<p><%= comment.story_id %> > <%= form_for [@comment, Subcomment.new] do |form| %> > <%= form.text_field :body %> > <p><%= form.submit %></p>
Ah, so since comment is clearly the comment for which you want create subcomments, that should be form_for [comment, Subcomment.new] - I had got the impression that this was on a single 'show' page for a particular comment (where @comment would usually be the comment being shown) Fred > <% end %> > </div> > </div> > <% end %> > > How do I 'make sure that @comment is set to the comment to which > subcomments should be added to' ? > > Neil > > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.