"238", "user_id"=>1, "group_id"=>43, "title"=>"asdas-6ren">
gpt4 book ai didi

ruby-on-rails - 为什么我得到 "Unpermitted parameter: format"?

转载 作者:行者123 更新时间:2023-12-05 07:49:40 24 4
gpt4 key购买 nike

我在 Rails Controller 中获取这些参数:

Parameters: {"id"=>"238", "user_id"=>1, "group_id"=>43, "title"=>"asdasdasd 1111 ultadas ult asdas", "description"=>"asdssss", "state_id"=>nil, "allow_anonymous_answer"=>false, "initial_message"=>"asdasdsadas", "final_message"=>"dasdasdsad", "poll_pages"=>[{"id"=>382, "poll_id"=>238, "title"=>"Pagina 1", "description"=>"Pagina 1", "position"=>1, "created_at"=>"2016-05-06T14:25:56.795Z", "updated_at"=>"2016-05-06T14:25:56.795Z"}], "poll"=>{"id"=>"238", "user_id"=>1, "group_id"=>43, "title"=>"asdasdasd 1111 ultadas ult asdas", "description"=>"asdssss", "state_id"=>nil, "allow_anonymous_answer"=>false, "initial_message"=>"asdasdsadas", "final_message"=>"dasdasdsad"}}

但我收到此消息:Unpermitted parameter: format

即使我正在使用:

params.permit(:id, :user_id, :title, :description, :state_id, :group_id, :allow_anonymous_answer, :initial_message, :final_message, poll: [:id, :user_id, :title, :description, :state_id, :group_id, :allow_anonymous_answer, :initial_message, :final_message], poll_pages: [:id, :poll_id, :title, :description, :position, :created_at, :updated_at])

最佳答案

您需要发送正确的格式,例如:

params.require(:MODEL).permit(:id, :user_id, :title, :description, :state_id, :group_id, :allow_anonymous_answer, :initial_message, :final_message, poll_attributes: [:id, :user_id, :title, :description, :state_id, :group_id, :allow_anonymous_answer, :initial_message, :final_message], poll_pages_attributes: [:id, :poll_id, :title, :description, :position, :created_at, :updated_at])  

还有 _attributes 用于您的许可参数中的嵌套属性:

poll_attributes: [:id, :user_id, :title, :description, :state_id, :group_id, :allow_anonymous_answer, :initial_message, :final_message]

关于ruby-on-rails - 为什么我得到 "Unpermitted parameter: format"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37076622/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com