title: How can i add into database column array from ruby on rails model?
body: <p>i have to following method </p>
  
  <pre><code>before_save :save_each_item_details
  
  def save_each_item_details
    items = itemname.length
    i = 0
  
    while i &lt; items
      items = itemname.length
      if !ItemsCensu.exists?(itname: itemname[i], year: "#{date.to_s.split('-').first}")
        ItemsCensu.create(itname: itemname[i], monadaM: mm[i], quntity: quantity[i], price: price[i], tax: tax[i], year: "#{date.to_s.split('-').first}", num_invoice &lt;&lt; invoice_num)
        i += 1
      else
        puts "test"
        i += 1
      end
    end
  end
  </code></pre>
  
  <p><code>num_invoice</code> is the array from database. <code>invoice_num</code> is a number like <code>1239</code> </p>
  
  <p>Each time I save it, I want it to to add the <code>invoice_num</code> into <code>num_invoice[]</code> without removing the old value.</p>
  
  <p>For example</p>
  
  <p>1st save:</p>
  
  <pre><code>invoice_num = 1234
  num_invoice &lt;&lt; invoice_num
  # =&gt; 1234
  </code></pre>
  
  <p>2nd save:</p>
  
  <pre><code>invoice_num = 12345
  num_invoice &lt;&lt; invoice_num
  # =&gt; [1234, 12345]
  </code></pre>
  
  <p>Is there a way to build this into my <code>ItemsCensu.create</code>, something like <code>ItemsCensu.create(num_invoice: &lt;&lt; invoice_num)</code>?</p>