回答

3
@video.comments.new(params[:comment].merge({:user_id => current_user.id})) 

我使用Hash#merge

+0

不錯,可我也把這段'@comment = @ video.comments.find(PARAMS [:ID ])在我的'destroy'行動? – 2011-04-06 02:52:29

+0

你會想要做的:'@ video.comments.find(params [:id],:conditions => {:user_id => current_user.id})' – 2011-04-06 02:53:35

0

你也可以這樣做:

@comment = @video.comments.new(params[:comment]) 
@comment.user = current_user