class Administrate::Field::ActiveStorage

Public Instance Methods

attached?() click to toggle source
# File lib/administrate/field/active_storage.rb, line 68
def attached?
  data.present? && data.attached?
end
attachments() click to toggle source
# File lib/administrate/field/active_storage.rb, line 72
def attachments
  many? ? data.attachments : [data.attachment] if attached?
end
blob_url(attachment) click to toggle source
# File lib/administrate/field/active_storage.rb, line 60
def blob_url(attachment)
  Rails.application.routes.url_helpers.rails_blob_path(attachment, disposition: :attachment, only_path: true)
end
can_add_attachment?() click to toggle source
# File lib/administrate/field/active_storage.rb, line 64
def can_add_attachment?
  many? || attachments.blank?
end
destroy_url() click to toggle source
# File lib/administrate/field/active_storage.rb, line 38
def destroy_url
  options.fetch(:destroy_url, nil)
end
direct?() click to toggle source
# File lib/administrate/field/active_storage.rb, line 34
def direct?
  options.fetch(:direct_upload, false)
end
index_display_count?() click to toggle source
# File lib/administrate/field/active_storage.rb, line 18
def index_display_count?
  options.fetch(:index_display_count) { attached? && attachments.count != 1 }
end
index_display_preview?() click to toggle source
# File lib/administrate/field/active_storage.rb, line 10
def index_display_preview?
  options.fetch(:index_display_preview, true)
end
index_preview_size() click to toggle source
# File lib/administrate/field/active_storage.rb, line 14
def index_preview_size
  options.fetch(:index_preview_size, [150, 150])
end
many?() click to toggle source
# File lib/administrate/field/active_storage.rb, line 30
def many?
  data.is_a? ::ActiveStorage::Attached::Many
end
preview(attachment, options) click to toggle source

work around since calling data.preview(options) returns “/images/<ActiveStorage::Preview>” which isnt the url

# File lib/administrate/field/active_storage.rb, line 48
def preview(attachment, options)
  Rails.application.routes.url_helpers.rails_representation_path(attachment.preview(options), only_path: true)
end
show_display_preview?() click to toggle source
# File lib/administrate/field/active_storage.rb, line 22
def show_display_preview?
  options.fetch(:show_display_preview, true)
end
show_preview_size() click to toggle source
# File lib/administrate/field/active_storage.rb, line 26
def show_preview_size
  options.fetch(:show_preview_size, [800, 800])
end
url(attachment) click to toggle source
# File lib/administrate/field/active_storage.rb, line 56
def url(attachment)
  Rails.application.routes.url_helpers.rails_blob_path(attachment, only_path: true)
end
variant(attachment, options) click to toggle source
# File lib/administrate/field/active_storage.rb, line 52
def variant(attachment, options)
  Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(options), only_path: true)
end