1
我想从一种形式创建同一模型的多个对象。 PARAMS,我在我的create
方法得到这个样子:Rails从一种形式创建多个对象的强参数
<ActionController::Parameters {"objects"=> <ActionController::Parameters {
"0"=>{priority"=>"24", "style"=>"three_pictures"},
"1"=>{"priority"=>"24", "style"=>"three_pictures"},
"2"=>{"priority"=>"24", "style"=>"three_pictures"}
} permitted: false>}permitted: false>
我感到困惑在这种情况下使用strong params
。我create
方法是这样的:
def create
params[:objects].each do |index, object|
Object.create(object.permit(:priority, :style))
end
...
end
这工作,但看起来不像这样做的正确方法。这应该怎么做?
我认为如果你不想绕过质量分配安全,它是正确的做法。 –