diff --git a/app/dashboards/archive_dashboard.rb b/app/dashboards/archive_dashboard.rb index 50d53ea38..a18e8790b 100644 --- a/app/dashboards/archive_dashboard.rb +++ b/app/dashboards/archive_dashboard.rb @@ -12,7 +12,7 @@ class ArchiveDashboard < Administrate::BaseDashboard created_at: Field::DateTime, updated_at: Field::DateTime, status: Field::String, - file: Field::HasOne + file: AttachmentField }.freeze # COLLECTION_ATTRIBUTES @@ -24,7 +24,8 @@ class ArchiveDashboard < Administrate::BaseDashboard :id, :created_at, :updated_at, - :status + :status, + :file ].freeze # SHOW_PAGE_ATTRIBUTES @@ -33,14 +34,6 @@ class ArchiveDashboard < Administrate::BaseDashboard :id, :created_at, :updated_at, - :status, - :file + :status ].freeze - - # Overwrite this method to customize how users are displayed - # across all pages of the admin dashboard. - # - def display_resource(archive) - "Archive : #{archive&.file.&byte_size}" - end end diff --git a/app/fields/attachment_field.rb b/app/fields/attachment_field.rb index 2022fb355..4a09d2d7e 100644 --- a/app/fields/attachment_field.rb +++ b/app/fields/attachment_field.rb @@ -1,8 +1,9 @@ require "administrate/field/base" class AttachmentField < Administrate::Field::Base + include ActionView::Helpers::NumberHelper def to_s - data.filename.to_s + "#{data.filename} (#{number_to_human_size(data.byte_size)})" end def blob_path