title: Rails: update an attribute to nil
body: <p>I have an integer column <code>post_id</code> that has a value in the db and I would like to update it to nil from the controller.</p>
  
  <p>I have tried the following but unfortunately the value remains the same and does not change to nil:</p>
  
  <pre><code>current_user.account.update(post_id: nil)
  current_user.account.update(post_id: 0)
  </code></pre>
  
  <p>Any ideas on how I can update the post id to nil?</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>Account table</p>
  
  <pre><code>create_table "accounts", force: :cascade do |t|
    t.string "name"
    t.string "street"
    t.string "city"
    t.string "state"
    t.string "postal_code"
    t.string "country"
    t.integer "post_id", default: 0
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end
  </code></pre>
  
  <p>the link to:</p>
  
  <pre><code>&lt;%= link_to "Remove post from user", remove_post_path, data: { confirm: "Are you sure?" } %&gt;
  </code></pre>
  
  <p>the route: </p>
  
  <pre><code>get "user/remove_post", to: "accounts#remove_post", :as =&gt; : remove_post
  </code></pre>
  
  <p>the controller method:</p>
  
  <pre><code>def remove_post
    current_user.account.update_attributes(post_id: nil)
  end
  </code></pre>
  
  <p>What i get in the console:</p>
  
  <pre><code>Account Update (0.6ms)  UPDATE "accounts" SET "post_id" = $1, "updated_at" = $2 WHERE "accounts"."id" = $3  [["post_id", 96], ["updated_at", "2019-02-27 10:43:53.432402"], ["id", 49]]
  </code></pre>