title: Rails Forms and Associations - Adding multiple objects with a quantity form
body: <p>I am new to rails, but not to programming or databases.  </p>
  
  <p>A BETTER PHRASING OF MY QUESTION IS IN MY ANSWER BELOW.</p>
  
  <p>For simplicity in this example, I have 3 models:
      User
      Subscription
      Default_Subscription</p>
  
  <pre><code>User has_many Subscriptions
  Subscription belongs_to User
  
  Default_Subscription has_many Subscriptions
  Subscription belongs_to Default_Subscription
  </code></pre>
  
  <p>Default_Subscription is a pre-populated table with certain types of subscriptions.</p>
  
  <p>During the subscription process, the default subscriptions are listed at one point, and there
  is a quantity box alongside each one.</p>
  
  <p>The user enters the quantities for each subscription and hits submit to continue on.</p>
  
  <p><b>My question is:
  How would one go about creating a new subscription for each quantity in a number form?</b></p>
  
  <p>So you would have a list something like so:</p>
  
  <pre><code>&lt;ol&gt;
     &lt;%= each subscription with quantity box %&gt;
  &lt;/ol&gt;
  
  &lt;%= button_to %&gt;
  </code></pre>
  
  <p>When the user hits the button, how do you add up the quantity from each box and add a new subscription for each one?  Do I have to use javascript to get the numbers?  Do I somehow use rails forms even though this quantities are not associated with any specific database field?  Any recommendations or pointing me in the right direction to figure this out on my own would be great.  </p>
  
  <p>This form box IS NOT A FIELD FOR ANY MODEL, it's a count for an association. Let me rephrase: Each quantity in the form boxes represent the number of NEW Subscriptions to be created. Each of these subscriptions BELONGS_TO 1 DEFAULT_SUBSCRIPTION. In essence, the number represents the number of new subscriptions ASSOCIATED WITH THAT DEFAULT SUBSCRIPTION.</p>
  
  <p>I'm using rails 3.2.1, and ruby 1.8.7</p>
  
  <p>Thank you</p>