[英]Ruby on Rails: How to chain strong parameter if some of the parameters are nested attributes?
假设我有以下参数:
"struct"=> {"content" => nil}, "name" => "structA"
当我尝试围绕它构建一个强大的参数过滤器时:
params = ActionController::Parameters.new("struct"=> {"content" => nil}, "name" => "structA")
params.permit(:struct, :name)
它仅接受名称:
=> {"name"=>"structA"}
我阅读了一些有关嵌套属性的文章,我需要使用“ require”:
params.require("struct").permit!
但是,如何将嵌套和非嵌套属性链接为一个过滤器?
尝试这个
params.permit(:struct => [:content], :name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.