While implementing the comment function Now it's jammed.
"=> {" content_id "=>" 468 "," comment "=>" Ah "},
why? And looking at the parameters, the values are being sent. .. .. Next, check the destination controller.
def comment_params
params.require(:comment).permit(:comment, :content_id)
end
permit is fine. Hmm? There is no key to be in pramas.require, right?
This → "" => {"content_id" => "468", "comment" => "Ah"},
Actually, I got stuck in the same place before and forgot to make the same mistake.
The answer is simple, just instantiate with the controller on the current page I'm a big fool (laughs)
This time I was working on the show page of the timeline function, so
time_line_controller.rb
def show
@content = Content.find(params[:id])
@user = User.find(@content.user_id)
@comment = Comment.new #I added this.
Add the above and try again!
"comment" => {"content_id" => "468", "comment" => "Ah"},
I got a parameter key! !!
Don't forget to create an instance on the current page even after creating a new model! that's all.
Thank you very much.
Recommended Posts