Set default value for datetime field in rails_admin

1.5k views Asked by At

As per the rails_admin github documentation here, for my rails model I have set default value for paramters as:

rails_admin do
  edit do
    field :active do
      default_value true
    end
    field :loyalty_tier do
      default_value 1
    end
  end
end

However, when I try to set the value for a datetime attribute, it is not reflecting on the corresponding admin panel view as expected.

The following code snippet:

rails_admin do
  edit do
    field :effective_start do
      default_value DateTime.now
    end
    field :effective_end do
      default_value {DateTime.now + 99.years}
    end
  end
end

renders the view as:

enter image description here

which does not render the time part of DateTime, as visible. How exactly to set the default value for a datetime field in rails_admin ?

0

There are 0 answers