Sha256: 9f1efca96c3a12bb0d72aa00f8868e7d57c91bd9bd96c0112ee4ab956c6bd165

Contents?: true

Size: 605 Bytes

Versions: 6

Compression:

Stored size: 605 Bytes

Contents

module Amalgam
  module AttachmentsHelper
    def link_to_attachment(attachment,url=nil,version=nil)
      return unless attachment
      if attachment.content_type.include?("image")
        file = version.present? ? attachment.file.send(version) : attachment.file
        content = image_tag(file)
      else
        content = attachment.original_filename
      end
      link = case url
             when nil then attachment.file.to_s
             when Symbol then attachment.send(url)
             when String then url
             end

      link_to_if link.present? , content ,link
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
amalgam-2.1.4.1 app/helpers/amalgam/attachments_helper.rb
amalgam-2.1.4 app/helpers/amalgam/attachments_helper.rb
amalgam-2.1.3.1 app/helpers/amalgam/attachments_helper.rb
amalgam-2.1.3 app/helpers/amalgam/attachments_helper.rb
amalgam-2.1.2 app/helpers/amalgam/attachments_helper.rb
amalgam-2.1.1 app/helpers/amalgam/attachments_helper.rb