Hello,

Good point - I have tried to amend the code like below, but i get
errors:

ORIGINAL CODE:
Blogpost.find(params[:id]).comments.create(params[:comment])

AMENDED CODE 1:
Blogpost.find(params[:id, :user_id]).comments.create(params[:comment])
THis returns error: wrong number of arguments (2 for 1)

AMENDED CODE 2:
 Blogpost.find(params[:id]).comments.create(params[:comment,:user_id])

THis also returns error: wrong number of arguments (2 for 1)

I'm sure it's quite simple, but can't put my finger on it.. Any ideas
what needs to change?

Many Thanks


On 9 May, 00:20, Frederick Cheung <[email protected]> wrote:
> On May 8, 5:15 pm, RubyonRails_newbie <[email protected]>
> wrote:
>
> >   def comment
> >     @user = User.find(session[:user_id])
> >     @blogpost = Blogpost.new
> >     @blogpost = Blogpost.create(:body => params[:body], :user_id =>
> > session[:user_id])
>
> >      Blogpost.find(params[:id]).comments.create(params[:comment])
>
> >      flash[:notice] = "Added your comment"
>
> >      redirect_to :action => "show", :id => params[:id]
>
> Unless user_id was part of the fields in params[:comment] you don't
> seem to be setting the user id on the comment anywhere.
>
> Fred
>
> --
> 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 
> athttp://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