Sha256: 1a509615b0b0c65058b0676504a782a41026a77b3c70e80320a49a2c95b225cb

Contents?: true

Size: 907 Bytes

Versions: 3

Compression:

Stored size: 907 Bytes

Contents

require "paperclip"
require "delayed_paperclip"

module DelayedPaperclip
  # On initialzation, include DelayedPaperclip
  class Railtie < Rails::Railtie
    initializer "delayed_paperclip.insert_into_active_record" do |app|
      ActiveSupport.on_load :active_record do
        DelayedPaperclip::Railtie.insert
      end

      if app.config.respond_to?(:delayed_paperclip_defaults)
        DelayedPaperclip.options.merge!(app.config.delayed_paperclip_defaults)
      end
    end
  end

  class Railtie
    # Glue includes DelayedPaperclip Class Methods and Instance Methods into ActiveRecord
    # Attachment and URL Generator extends Paperclip
    def self.insert
      ActiveRecord::Base.send(:include, DelayedPaperclip::Glue)
      Paperclip::Attachment.prepend(DelayedPaperclip::Attachment)
      Paperclip::Attachment.default_options[:url_generator] = DelayedPaperclip::UrlGenerator
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
kt-delayed_paperclip-3.1.1 lib/delayed_paperclip/railtie.rb
kt-delayed_paperclip-3.1.0 lib/delayed_paperclip/railtie.rb
delayed_paperclip-3.0.1 lib/delayed_paperclip/railtie.rb