Sha256: ae45ac64f2a363afdad52068944ad8e9586a19e911169e65244a65748bc80a86
Contents?: true
Size: 964 Bytes
Versions: 13
Compression:
Stored size: 964 Bytes
Contents
# frozen_string_literal: true require 'rails_admin/config/fields/base' require 'rails_admin/config/fields/types/file_upload' module RailsAdmin module Config module Fields module Types # Field type that supports Paperclip file uploads class Paperclip < RailsAdmin::Config::Fields::Types::FileUpload RailsAdmin::Config::Fields::Types.register(self) register_instance_option :delete_method do "delete_#{name}" if bindings[:object].respond_to?("delete_#{name}") end register_instance_option :thumb_method do @styles ||= bindings[:object].send(name).styles.collect(&:first) @thumb_method ||= @styles.detect { |s| [:thumb, 'thumb', :thumbnail, 'thumbnail'].include?(s) } || @styles.first || :original end def resource_url(thumb = false) value.try(:url, (thumb || :original)) end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems