I have code like this:
ActiveAdmin.register Post do
form do |f|
f.inputs "Post Details" do
f.input :title
f.input :body
f.input :published_at, :as => DateTime.now
end
f.actions
end
I want the field :published_at
(which is t.datetime) to be set to the current date and time by default. My example doesn't work. How can I achieve this?
Yep. Found the answer myself.
ActiveAdmin.register Post do
form do |f|
f.object.published_at = DateTime.now
f.inputs "Post Details" do
f.input :title
f.input :body
f.input :published_at
...
end
end
You can try with something like this:
<%= f.input :published_at, input_html: {value: "#{Time.now}"} %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With