title: Strong parameters with nested hash
body: <p>I have the following params and cannot get the strong parameters to work.</p>
  
  <p>Here's my basic code, runnable in the Rails console for simplicity:</p>
  
  <pre><code>json = {
    id: 1,
    answers_attributes: {
      c1: { id: "", content: "Hi" },
      c2: { id: "", content: "Ho" }
    }
  }
  
  params = ActionController::Parameters.new(json)
  </code></pre>
  
  <p>Everything I've read says the following should work, but it only gives me the <code>id</code> and an empty hash of <code>answers_attributes</code>:</p>
  
  <pre><code>params.permit(:id, answers_attributes: [:id, :content])
  =&gt; { "id"=&gt;1, "answers_attributes"=&gt;{} }
  </code></pre>
  
  <p>If I instead manually list <code>c1</code> and <code>c2</code> (like below) it works, but this is really stupid because I don't know how many answers the user will supply, and this is a lot of duplication:</p>
  
  <pre><code>params.permit(:id, answers_attributes: { c1: [:id, :content], c2: [:id, :content] })
  =&gt; {"id"=&gt;1, "answers_attributes"=&gt;{"c1"=&gt;{"id"=&gt;"", "content"=&gt;"Hi"}, "c2"=&gt;{"id"=&gt;"", "content"=&gt;"Ho"}}}
  </code></pre>
  
  <p>I've tried replacing <code>c1</code> and <code>c2</code> with <code>0</code> and <code>1</code>, but I still have to manually supply the <code>0</code> and <code>1</code> in my permit statement.</p>
  
  <p>How can I permit an unknown length array of nested attributes?</p>