Rails Active Admin datetime input does not load the current date and time?
Is there any option for formtastic in Active Admin, for the showing current datetime in datetime input. It's coming with bla开发者_JS百科nk on the form load.
There is no direct way to do this. However there are multiple options to do this
1- if you want to go with default feature provided by formtastic(drop down type time selection) then in the model class:
def after_initialize
self.start_time ||= Time.now
end
Then when the form is displayed, it will already have the time populated and set correctly.
2- if you want to just show date then you can use
f.input :start_time, :as => :datepicker, :html_option => { value: Time.now }
3- use https://github.com/activeadmin-plugins/active_admin_datetimepicker gem
精彩评论