Sha256: 25282f273ccca1cfdd9b05260ecab1dd09b26e2b0477617d10e38fe796ace675

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

require 'dragonfly'
require 'uri'

### The dragonfly app ###
app = Dragonfly[:images]
app.configure_with(:rails)
app.configure_with(:imagemagick)

### Extend active record ###
if defined?(ActiveRecord::Base)
  app.define_macro(ActiveRecord::Base, :image_accessor)
  app.define_macro(ActiveRecord::Base, :file_accessor)
end

### Insert the middleware ###
Rails.application.middleware.insert 0, 'Dragonfly::Middleware', :images

begin
  require 'rack/cache'
  Rails.application.middleware.insert_before 'Dragonfly::Middleware', 'Rack::Cache', {
    :verbose     => true,
    :metastore   => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded because Windows
    :entitystore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")  # has problems with spaces
  }
rescue LoadError => e  
  app.log.warn("Warning: couldn't find rack-cache for caching dragonfly content")
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
dragonfly-0.9.0 lib/dragonfly/rails/images.rb
oahu-dragonfly-0.8.2 lib/dragonfly/rails/images.rb