Sha256: 8ea899ada2540f07d1b3013339e6808bbc5b4138aedbc17cdc6e36051294f663
Contents?: true
Size: 840 Bytes
Versions: 1
Compression:
Stored size: 840 Bytes
Contents
module ActiveAdminAddons module PaperclipImage class << self def image(context, model, attribute, options) img = model.send(attribute) return nil if img.nil? raise 'you need to pass a paperclip image attribute' unless img.respond_to?(:url) style = options.fetch(:style, :original) context.image_tag(img.url(style)) if img.exists? end end end module ::ActiveAdmin module Views class TableFor def image_column(attribute, options = {}) column(attribute) { |model| PaperclipImage.image(self, model, attribute, options) } end end class AttributesTable def image_row(attribute, options = {}) row(attribute) { |model| PaperclipImage.image(self, model, attribute, options) } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activeadmin_addons-0.2.1 | lib/activeadmin_addons/addons/paperclip_image.rb |