title: Saving a hash to the DB that contains arrays of the forms submitted data
body: <p>I have a form that saves the values into hashes. And from the controller the hash is saved to the db.</p>
  
  <p>Here is the form</p>
  
  <pre><code>   &lt;%= form_for([@category, @page], url: update_pages_path) do |f| %&gt;
     &lt;%= render 'shared/error_messages', object: f.object %&gt;
  
       &lt;%= text_field_tag 'content[key1]' %&gt;
  
       &lt;%= text_field_tag 'content[key2]' %&gt;
  
       &lt;%= text_field_tag 'content[key3]' %&gt;
  
       &lt;%= text_field_tag 'content[key4]' %&gt;
       &lt;%= f.submit "Save"  %&gt;
  
     &lt;% end %&gt;
  </code></pre>
  
  <p>Here is where the hash is saved to the DB</p>
  
  <pre><code>  if @page.update (category_params)
     @page.update(table_content: params[:content])
     redirect_to show_pages_path(@category, @page)
     flash[:success] = "Updated."
     else
     render 'edit'
    end
  </code></pre>
  
  <p>I need to change the form so the value in the hash will be an array. And from the form the user can add items to the value array.</p>
  
  <p>This is what the info is saved as to the db currently</p>
  
  <pre><code>{"key1"=&gt;"value1", "key2"=&gt;"value2", "key3"=&gt;"value3", "key4"=&gt;"value4"}
  </code></pre>
  
  <p>and I need it to change to this</p>
  
  <pre><code>{"key1"=&gt;["value1"], "key2"=&gt;["value2"], "key3"=&gt;["value3"], "key4"=&gt;["value4"]}
  </code></pre>
  
  <p>So ultimately something like this is possible to be saved to the db from the form and through the controller</p>
  
  <pre><code>{"key1"=&gt;["value1a","value1b"], "key2"=&gt;["value2"], "key3"=&gt;["value3a", "value3b"], "key4"=&gt;["value4"]}
  </code></pre>
  
  <p>I will be using js so the user can add and remove inputs but I first need to know what the form setup will be like before I start on that.</p>
  
  <p>For now for simplicity what would the form and maybe controller need to look like to save the bottom hash to the DB. </p>
  
  <p>What part of <code>'content[1]'</code> needs to be changed so I can have another input add to the key <code>key1</code> value array.</p>
  
  <p>I cant find how to have the inputs save as arrays let alone how to have 2 inputs save to the same key as part of an array. </p>
  
  <p>Basically what would need to be done to save the third array listed to the DB from changing the form and controller I have.</p>