Sha256: 31ccaf56a7257dee3314f30a0069a7e304a2a763cf0fde341af26222b7d82775
Contents?: true
Size: 977 Bytes
Versions: 15
Compression:
Stored size: 977 Bytes
Contents
require 'rails_admin/config/fields/base' require 'rails_admin/config/fields/types/file_upload' module RailsAdmin module Config module Fields module Types class Carrierwave < RailsAdmin::Config::Fields::Types::FileUpload RailsAdmin::Config::Fields::Types.register(self) register_instance_option :thumb_method do @thumb_method ||= ((versions = bindings[:object].send(name).versions.keys).find{|k| k.in?([:thumb, :thumbnail, 'thumb', 'thumbnail'])} || versions.first.to_s) end register_instance_option :delete_method do "remove_#{name}" end register_instance_option :cache_method do "#{name}_cache" end def resource_url(thumb = false) return nil unless (uploader = bindings[:object].send(name)).present? thumb.present? ? uploader.send(thumb).url : uploader.url end end end end end end
Version data entries
15 entries across 15 versions & 2 rubygems