Class: RailsAdmin::Config::Fields::Types::ActiveStorage

Inherits:
FileUpload
  • Object
show all
Defined in:
lib/rails_admin/config/fields/types/active_storage.rb

Constant Summary

Constants inherited from Base

Base::NAMED_INSTANCE_VARIABLES

Instance Attribute Summary

Attributes inherited from Base

#abstract_model, #defined, #name, #order, #parent, #properties, #root, #section

Instance Method Summary collapse

Methods inherited from FileUpload

#virtual?

Methods inherited from Base

#association?, #editable?, #errors, #form_default_value, #form_value, #generic_field_help, #generic_help, #initialize, #inverse_of, #method_name, #optional, #optional=, #optional?, #parse_input, #parse_value, #type, #type_css_class, #virtual?

Methods included from Inspectable

#inspect

Methods included from Groupable

#group

Methods included from Hideable

#hidden?, #hide, included, #show

Methods included from Configurable

#has_option?, #register_deprecated_instance_option, #register_instance_option

Methods included from Proxyable

#bindings, #bindings=, #with

Constructor Details

This class inherits a constructor from RailsAdmin::Config::Fields::Base

Instance Method Details

#resource_url(thumb = false) ⇒ Object


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rails_admin/config/fields/types/active_storage.rb', line 24

def resource_url(thumb = false)
  return nil unless value
  if thumb && value.variable?
    thumb = thumb_method if thumb == true
    variant = value.variant(thumb)
    Rails.application.routes.url_helpers.rails_blob_representation_path(
      variant.blob.signed_id, variant.variation.key, variant.blob.filename, only_path: true
    )
  else
    Rails.application.routes.url_helpers.rails_blob_path(value, only_path: true)
  end
end

#valueObject


37
38
39
40
# File 'lib/rails_admin/config/fields/types/active_storage.rb', line 37

def value
  attachment = super
  attachment if attachment && attachment.attached?
end