title: How to make a serialized column empty?
body: <p>I have a column in Company, that is serialized as Array:</p>
  
  <pre><code>class Company
    serialize :column_name, Array
  end
  </code></pre>
  
  <p>In <strong>rails console</strong>, when I try the following:</p>
  
  <pre><code>existing = Company.last.column_name
  # it gives a array with single element, say [1]
  existing.delete(1)
  # now existing is []
  Company.last.update_attributes!(column_name: existing)
  # It empties the array, so:
  Company.last.column_name #gives []
  </code></pre>
  
  <p>But, when I try the same code in <code>remove</code> method of some controller, it never removes the last element. It always returns [1].</p>
  
  <p><strong>How can I empty the serialized column?</strong></p>
  
  <p><strong>NOTE:-</strong> This logic works when I have multiple elements, but doesn't work for the last element alone.</p>
  
  <p><strong>CONTROLLER CODE</strong></p>
  
  <pre><code>def remove_restricted_num
    company = Company.where(id: params[:id]).first
    restricted_numbers = company.restricted_numbers
    num = params[:num].to_i
  
    if restricted_numbers.include?(num)
      restricted_numbers.delete(num)
      company.update_attributes!(restricted_numbers: restricted_numbers)
  
      render js: "alert('#{num} was removed')"
    else
      render js: "alert('Number not found in the list')"
    end
  end
  </code></pre>