title: Rails forms: how to store two text_fields in one array
body: <p>Newbie to rails and on many online tutorials I see this example</p>
  
  <pre><code>&lt;div class="field"&gt;
   &lt;%= f.label :first_name %&gt;&lt;br /&gt;
   &lt;%= f.text_field :first_name %&gt;
  &lt;/div&gt;
  &lt;div class="field"&gt;
   &lt;%= f.label :last_name %&gt;&lt;br /&gt;
   &lt;%= f.text_field :last_name %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>which stores like this </p>
  
  <pre><code>"first_name"=&gt;"foo", "last_name"=&gt;"bar"
  </code></pre>
  
  <p>Is there a way use text_field or another form attribute to store two inputs in an array, so it would end up something like:  </p>
  
  <pre><code>"name"=&gt;["foo", "bar"]
  </code></pre>
  
  <p>This is not the preferred way, but curious to see how it would be done </p>
  
  <p>Update</p>
  
  <p>In your example you are passing @user.first_name and .last_name as the value. I was thinking more something more like this:</p>
  
  <pre><code> &lt;div class="field"&gt;
    &lt;%= f.label "First Name" %&gt;&lt;br /&gt;
    &lt;%= f.text_field :name %&gt;
  &lt;/div&gt;
  &lt;div class="field"&gt;
   &lt;%= f.label "Last Name" %&gt;&lt;br /&gt;
   &lt;%= f.text_field :name %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>where there is no <code>@user.first_name</code> but <code>@user.name[0]</code></p>