title: rails_admin won't let me keep my enum field as nil
body: <p>Model:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class Reservation &lt; ApplicationRecord
    # https://naturaily.com/blog/ruby-on-rails-enum
    enum recurrence: {
      daily: 0,
      weekly: 1,
      monthly: 2,
      annually: 3
    }, _prefix: :recurring
  
    belongs_to :user
  
    validates :name, :user_id, presence: true
    ...
  end
  </code></pre>
  
  <p>Migration:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class CreateReservations &lt; ActiveRecord::Migration[5.2]
    def change
      create_table :reservations do |t|
        t.string 'name', null: false
        ...
        t.boolean 'recurring', default: false, null: false
        t.integer 'recurrence', index: true, allow_blank: true, default: nil # trying a lot of things here
        t.datetime 'expire_time'
        ...
      end
    end
  end
  </code></pre>
  
  <p>Works as expected in the console:</p>
  
  <pre class="lang-rb prettyprint-override"><code>2.4.5 :002 &gt; res = Reservation.new(name: 'test', user_id: 1)
   =&gt; #&lt;Reservation id: nil, name: "test", recurring: false, recurrence: nil, date: nil, start_time: nil, end_time: nil, expire_time: nil, user_id: 1, created_at: nil, updated_at: nil&gt;
  
  2.4.5 :003 &gt; res.valid?
    User Load (0.7ms)  SELECT  "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
   =&gt; true
  
  2.4.5 :004 &gt; res.save
     (0.2ms)  BEGIN
    Reservation Create (0.5ms)  INSERT INTO "reservations" ("name", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["name", "test"], ["user_id", 1], ["created_at", "2019-09-24 20:42:40.933959"], ["updated_at", "2019-09-24 20:42:40.933959"]]
     (2.1ms)  COMMIT
   =&gt; true
  
  2.4.5 :005 &gt; res.reload
    Reservation Load (0.3ms)  SELECT  "reservations".* FROM "reservations" WHERE "reservations"."id" = $1 LIMIT $2  [["id", 5], ["LIMIT", 1]]
   =&gt; #&lt;Reservation id: 5, name: "test", recurring: false, recurrence: nil, date: nil, start_time: nil, end_time: nil, expire_time: nil, user_id: 1, created_at: "2019-09-24 20:42:40", updated_at: "2019-09-24 20:42:40"&gt; 
  
  2.4.5 :006 &gt; res.recurrence
   =&gt; nil 
  </code></pre>
  
  <p>And yet, in Rails Admin, when I create or edit a record, they all get assigned to the first enum. Even when I intentionally delete the value from the form, it still saves the record with the first enum value.</p>
  
  <p>Rails Admin:</p>
  
  <pre class="lang-rb prettyprint-override"><code>config.model Reservation do
      weight 2
      parent Event
      list do
        field :name
        field :display_date do
          formatted_value { bindings[:object].display_date }
        end
        field :recurrence, :active_record_enum # should be unnecessary, but trying everything
        field :expire_time
        field :user do
          label 'Creator'
          formatted_value { bindings[:object].user.name }
        end
      end
    end
  </code></pre>
  
  <p>I have tried:</p>
  
  <ul>
  <li> not indexing this field (thinking Rails Admin wants a value for indexed columns)
  <li> ensuring `:active_record_enum` is declared on `field :recurrence`
  </ul>
  
  <p>As suggested, here's the related section of the log:</p>
  
  <pre class="lang-rb prettyprint-override"><code>Started POST "/admin/reservation/new" for ::1 at 2019-09-25 10:09:50 -0400
  Processing by RailsAdmin::MainController#new as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"VbhHM7YD+oQvwMYIQzMHyT5e0MXFFuN3pyH/1s6yM8n6kqKvywZ5E8zaABMKhOU+oWpfU1Kk55FWYjL9TzbkbQ==", "reservation"=&gt;{"name"=&gt;"logs", "date"=&gt;"", "start_time"=&gt;"", "end_time"=&gt;"", "recurring"=&gt;"0", "recurrence"=&gt;"", "expire_time"=&gt;"", "start_time_of_day"=&gt;"", "end_time_of_day"=&gt;"", "day_of_week"=&gt;"", "date_of_month"=&gt;"", "date_of_year"=&gt;"", "user_id"=&gt;"1"}, "return_to"=&gt;"http://localhost:3000/admin/reservation", "_save"=&gt;"", "model_name"=&gt;"reservation"}
    User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]
     (0.2ms)  BEGIN
    User Load (0.6ms)  SELECT  "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
    Reservation Create (0.4ms)  INSERT INTO "reservations" ("name", "recurrence", "day_of_week", "date_of_month", "date_of_year", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"  [["name", "logs"], ["recurrence", 0], ["day_of_week", ""], ["date_of_month", ""], ["date_of_year", ""], ["user_id", 1], ["created_at", "2019-09-25 14:09:50.926864"], ["updated_at", "2019-09-25 14:09:50.926864"]]
     (1.3ms)  COMMIT
  Redirected to http://localhost:3000/admin/reservation
  Completed 302 Found in 26ms (ActiveRecord: 3.0ms)
  </code></pre>
  
  <p>And, sure enough the param <code>"recurrence"=&gt;""</code> is transformed into <code>["recurrence", 0]</code></p>
  
  <p>It seems to be a <a href="https://github.com/sferik/rails_admin/issues/2993" rel="nofollow noreferrer">known issue</a>, but if it's a legit bug, I still need help with a work-around. Anyone solved this already?</p>