Why can't I see datetime fields in rails_admin show view?

I am adding a new model to rails_admin. The list page displays the datetime fields correctly, even without any configuration. But the detail page (show) for this object does not display data. How to configure rails_admin to display date and time fields on the display page?

Model File: alert_recording.rb:

class AlertRecording < ActiveRecord::Base
  attr_accessible :user_id, :admin_id, :message, :sent_at, :acknowledged_at, :created_at, :updated_at
end

Rails_admin Initialization File:

...
config.included_models = [
  AlertRecording
]

...

config.model AlertRecording do
  field :sent_at, :datetime
  field :acknowledged_at, :datetime
  field :message
  field :user
  field :admin
  field :created_at, :datetime
  field :updated_at, :datetime
  list do; end
  show do; end
end

What is the right way to configure datetime fields so that I see them in a view?

+4
source share
2 answers

What you have for sent_atand acknowledged_atshould work. Make sure the records you are trying to "show" have dates for these fields.

created_at updated_at this:

config.model AlertRecording do
  field :created_at
  configure :created_at do
    show
  end
  field :updated_at, :datetime
  configure :updated_at do
    show
  end
end
+1

, :

https://github.com/sferik/rails_admin/blob/ead1775c48754d6a99c25e4d74494a60aee9b4d1/lib/rails_admin/config.rb#L277

, config/initializers/rails_admin.rb :

config.default_hidden_fields = []

- :

config.default_hidden_fields = [:id, :my_super_top_secret_field]

, ;)

!!!. , id, created_at updated_at .

, :

config.default_hidden_fields = {
  show: [],
  edit: [:id, :created_at, :updated_at]
}

, , .;)

+1

All Articles