title: Can't figure out why form won't save to database ruby on rails
body: <p>I am trying to save a "product" aka pair of glasses to a database with the following data fields-- Name, Lens, Frame, Temple, Accent, Quantity, Photo. </p>
  
  <p>app/controllers/product_controller.rb</p>
  
  <pre><code>def create
     @product = Product.create(product_params)
  
  end
  
  # Each pair of glasses has a name, lens, frame, accent, quantity, and picture
  def product_params
     params.require(:product).permit(:name, :lens_id, :frame_id, :temple_id, :accent_id, :quantity, :photo)
  end
  </code></pre>
  
  <p>app/views/products/_form.html.erb</p>
  
  <pre><code>&lt;div class="field"&gt;
      ....
      &lt;%= f.label :quantity %&gt;
      &lt;%= number_field_tag :quantity, nil, class: 'form-control', min: 1
  &lt;/div&gt;  
  </code></pre>
  
  <p>I can save the record and everything saves to the database except quantity which saves as 'nil'. I can go into the rails console, select that record, and manually add a quantity via the console though... what am I missing?</p>
  
  <p>Thanks in advance!</p>