Dragonfly can be used with any ActiveModel-compatible model, therefore libraries like Mongoid work out of the box.

Furthermore, Mongo DB has support for storing blob-like objects directly in the database (using MongoDB 'GridFS'), so you can make use of this with the supplied MongoDataStore.

For more info about ActiveModel, see Models.

For more info about using the Mongo data store, see DataStorage.

Example setup in Rails, using Mongoid

In config/initializers/dragonfly.rb:

require 'dragonfly'

app = Dragonfly[:images]

# Configure to use ImageMagick, Rails defaults, and the Mongo data store
app.configure_with(:rails) do |c|
  c.datastore = :db => Mongoid.database

# Allow all mongoid models to use the macro 'image_accessor'
app.define_macro_on_include(Mongoid::Document, :image_accessor)

# ... any other setup, see Rails docs

Then in models:

class Album
  include Mongoid::Document

  field :cover_image_uid
  image_accessor :cover_image

  # ...

See Models for more info.