Ruby on Rails Tuesday, March 27, 2012

so basically its not params[:user_id] it's params[:comment][:user_id]
Ahmy Yulrizka


On Tue, Mar 27, 2012 at 11:17 PM, Neil Bye <lists@ruby-forum.com> wrote:
Cpx Cpx wrote in post #1053588:
> This line:
> post :create, :comment => @comment.attributes
>
> The second parameter (hash) is the content of params in your controller.
> So
> basically your params[:comment] would be @comment.attributes
>
> So if you expected params[:user_id] then you should pass it to the post
> call
>
> Ahmy Yulrizka

:user_id is one of the attributes

 setup do
   @comment = comments(:hello)
   @comment.commenter = "cleb"
   @comment.body = "hello"
   @comment.user_id = 1
 end

Neil

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

No comments:

Post a Comment