module SnipSnap::PaperclipExtension

Public Class Methods

registered(app) click to toggle source
# File lib/snipsnap/extensions/paperclip.rb, line 15
def self.registered(app)
  app.configure do
    Paperclip.io_adapters.register FileAdapter do |target|
      begin
        target.is_a?(Hash) && Tempfile === target[:tempfile]
      rescue => e
        false
      end
    end

    Paperclip.interpolates :rails_root  do |attachment, style|
      app.root
    end

    Paperclip.interpolates :guid  do |attachment, style|
      attachment.instance.guid
    end

    Paperclip.options[:command] = `which convert`
    Paperclip::Attachment.default_options.tap do |config|
      config[:url] = "/:attachment/:guid-:style.:extension"
    end
  end
end