0
강력한 매개 변수에 문제가 있습니다.강력한 매개 변수, 허용되지 않은 매개 변수
내 교체 된 매개 변수는 다음과 같습니다 전달되는
def post_params
params.require(:post).permit(:content, :user_id, :topic_id).merge(:user_id => get_user.id)
end
매개 변수는 다음과 같습니다
{"utf8"=>"✓",
"authenticity_token"=>"5+OEnLgihamJC37BSn4r/spoiRmccJzHhe6eaeC2Fuc=",
"post"=>{"topid_id"=>"10",
"content"=>"awfawfaw"}}
그리고 함수를 작성한다 :
def create
post = Post.new(post_params)
if post.valid? && post.save
redirect_to :controler => :topic, :action => :show, :topic => post.topic.id
end
end
콘솔에서 오류가 발생했습니다. 왜 허용되지 않는지 알고 싶습니다 topic_id
. 당신이해야하는
입니다
:
오타가 있습니다. 로그에'topic_id' 대신'topid_id'가 표시됩니다. – mccannf
신의 축복을 부탁드립니다.) –
오류 또는 텍스트를 화면 캡처하지 않을 때 도움이됩니다. 대신 텍스트를 복사하여 붙여넣고 합리적으로 읽을 수있는 형식으로 서식을 지정하십시오. –