On Tue, Apr 19, 2011 at 1:52 PM, Neil Bye <[email protected]> wrote:
> Im trying to makee an application that allows subcomments ie comments on
> comments. The point where I get stuck is finding the comment that is
> commented on.
>
> This is an excerpt from subcomment.rb
>
> 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
>

Is there any reason you're using create instead of build? This is how
I would code it.

@comment.subcomments.build(params[:subcomment])

Note: I haven't tested it, etc. etc.

Trevor Oke

> The second line is obviously wrong (and bviously works if I give a value
> for :id) so I think I might have the wrong approach.
>
> Can anyone shed light on this issue.
>
> --
> Posted via http://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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to