class Administrate::Field::ActiveStorage
Public Instance Methods
blob_url(attachment)
click to toggle source
# File lib/worker/field/active_storage.rb, line 45 def blob_url(attachment) Rails.application.routes.url_helpers.rails_blob_path(attachment, disposition: :attachment, only_path: true) end
destroy_path(field, attachment)
click to toggle source
# File lib/worker/field/active_storage.rb, line 49 def destroy_path(field, attachment) destroy_path_helper = options.fetch(:destroy_path) record_id = field.data.record.id attachment_id = attachment.id Rails.application.routes.url_helpers.send(destroy_path_helper, {:record_id => record_id, :attachment_id => attachment_id}) end
destroyable?()
click to toggle source
# File lib/worker/field/active_storage.rb, line 14 def destroyable? options.key?(:destroy_path) end
direct?()
click to toggle source
# File lib/worker/field/active_storage.rb, line 23 def direct? options.fetch(:direct_upload, false) end
many?()
click to toggle source
# File lib/worker/field/active_storage.rb, line 18 def many? # find a way to use instance_of data.class.name == "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/worker/field/active_storage.rb, line 37 def preview(attachment, options) Rails.application.routes.url_helpers.rails_representation_path(attachment.preview(options), only_path: true) end
url(attachment)
click to toggle source
# File lib/worker/field/active_storage.rb, line 41 def url(attachment) Rails.application.routes.url_helpers.rails_blob_path(attachment, only_path: true) end
url_only?()
click to toggle source
# File lib/worker/field/active_storage.rb, line 10 def url_only? options.fetch(:url_only, false) end