Permit dynamical child param

Viewed 29

I have a params from form:

{"utf8"=>"✓",
 "authenticity_token"=>"token",
 "collection_template"=>
  {"id"=>"",
   "status"=>"0",
   "name"=>"a",
   "global_title"=>"a",
   "global_description"=>"a",
   "document_templates"=>{"document_5ec63cc39445"=>{"document_id"=>"9d606a73-7467-4fd6-a65a-6529992b6144", "required"=>"true"}}},
 "commit"=>"Save"}

And I need to permit dynamical created

document_5ec63cc39445

Where 5ec63cc39445 is always dynamical number Number of documents can be set up to 10

1 Answers

Danil Kravchenko

Here it is!

params.require(:collection_template).permit(document_templates: {})

Here's the guide about Permitted Scalar Values from Rails Official Doc for your reference.

hope that helps

NOTE: I only included the one you specifically asked, so, you may add the other permitted params on your own

Related