title: Disable number_field when radio button is not checked
body: <p>I'm trying to make a form and only show a number_field if it's relative radio button is checked. I'm able to hide the number_field with CSS, but since all the number_fields have the same name, the app only saves at the database the last field (even if its related radio is unchecked, since the CSS is only hiding the field). There is a way to send the number_field data to database only if it's relative radio button is checked?</p>
  
  <p>To illustrate the problem with other words: If this code generates 5 radio buttons, when it is sent to the database, the value of the last number_field is the final value written in the database, while I wish that only the value of the number_field with the relative radio_button selected is sent to the database.</p>
  
  <p>There is a way of doing that within the controller or the model?</p>
  
  <p>My view:</p>
  
  <pre><code>&lt;% @shipping_method_list.each do |shipping| %&gt;
    &lt;div&gt;
      &lt;%= f.radio_button :shipping_method_id, shipping.id %&gt;
      &lt;% @sm_id = :shipping_method_id.to_s + "_" + shipping.id.to_s %&gt;
      &lt;%= f.label @sm_id, shipping.name %&gt;
      &lt;span class="reveal-if-active"&gt;Cost: &lt;%= f.number_field :shipping_cost %&gt;&lt;/span&gt; # This is what I want to disable when the radio isn't checked.
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>And my CSS:</p>
  
  <pre><code>.reveal-if-active {
      opacity: 0;
      max-height: 0;
      overflow: hidden;
  }
  
  input[type="radio"]:checked ~ .reveal-if-active,
  input[type="checkbox"]:checked ~ .reveal-if-active {
    opacity: 1;
    max-height: 100px;
    overflow: visible;
  }
  </code></pre>