Module: ResourceRow::PaperclipExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/extensions/concerns/resource_row/paperclip_extensions.rb

Instance Method Summary collapse

Instance Method Details

#thumbnail(attachment_name, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'app/extensions/concerns/resource_row/paperclip_extensions.rb', line 7

def thumbnail(attachment_name, options = {})
  options.reverse_merge!(style: :original)
  style = options.delete(:style)

  attachment = resource.send(attachment_name)
  return column(attachment_name) unless attachment.respond_to?(:url)

  image_tag = h.image_tag(attachment.url(style))
  column(attachment_name) { |resource| h.link_to(image_tag, h.send("#{resource.class.name.demodulize.underscore}_path", resource)) }
end