title: Rails loop with number_field params?
body: <p>I use two number_field to get numbers, and <code>if minor_sum &gt; minor</code>, I will create <code>minor_sum - minor +1</code> objects.</p>
  
  <pre><code>&lt;%= f.number_field :minor, :class =&gt; "form-control" ,placeholder: "(1~9999)" %&gt;
  &lt;%= number_field :minor_sum, nil, :class =&gt; "form-control" , placeholder: "(1~9999)" %&gt;
  </code></pre>
  
  <p>But when I enter two number <strong>111,112</strong> and create, It's shows</p>
  
  <blockquote>
    <p>comparison of String with Array failed</p>
  </blockquote>
  
  <p>and mark this line:</p>
  
  <blockquote>
    <p>if minor.present? &amp;&amp; minor_sum.present? &amp;&amp; minor &lt; minor_sum</p>
  </blockquote>
  
  <p>the following is my controller:</p>
  
  <pre><code>def create
      minor = params[:beacon][:minor] if params[:beacon][:minor].present?
      minor_sum = params[:minor_sum] if params[:minor_sum].present?
  
      if minor.present? &amp;&amp; minor_sum.present? &amp;&amp; minor &lt; minor_sum.to_i
  
          while minor &lt; minor_sum
            @beacon = Beacon.new(beacon_params)
  
            ...
  
            minor += 1
          end 
      else
         ...
      end
  end
  </code></pre>
  
  <p>Does it means that I got params from number_field is not number? How yo solve it?</p>
  
  <p>I tried <strong>.to_i</strong>, shows:</p>
  
  <blockquote>
    <p>undefined method `to_i' for ["112"]:Array</p>
  </blockquote>
  
  <p>mark this line:</p>
  
  <blockquote>
    <p>if minor.present? &amp;&amp; minor_sum.present? &amp;&amp; minor.to_i &lt; minor_sum.to_i</p>
  </blockquote>