diff --git a/app/models/notice.rb b/app/models/notice.rb index b97e4b68..7b9a2035 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -124,6 +124,7 @@ class Notice < ApplicationRecord # == Scopes =============================================================== scope :top_notices_token_urls, -> { joins(:archived_token_urls).select('notices.*, COUNT(archived_token_urls.id) AS counted_archived_token_urls').group('notices.id') } + scope :with_attachments, -> { includes(:file_uploads).where.not(file_uploads: { id: nil }) } # == Aliases ============================================================== alias_attribute :tags, :tag_list diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index a1d5d1e1..6c9c69a0 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -74,6 +74,8 @@ # avoid calling it. limited_pagination true + scopes [nil, :with_attachments] + field :id field :title field(:date_sent) { label 'Sent' }