Sha256: 4e6294f041d48914d0c9579d75c308e16712ed87e5a10ce5251c7d4f5effd846
Contents?: true
Size: 1.37 KB
Versions: 9
Compression:
Stored size: 1.37 KB
Contents
Mongo ===== Dragonfly can be used with any ActiveModel-compatible model, therefore libraries like [Mongoid](http://mongoid.org) 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 {Dragonfly::DataStorage::MongoDataStore MongoDataStore}. For more info about ActiveModel, see {file:Models}. For more info about using the Mongo data store, see {file:DataStorage}. Example setup in Rails, using Mongoid ------------------------------------- In config/initializers/dragonfly.rb: require 'dragonfly' app = Dragonfly[:images] # Get database name from config/mongoid.yml db = YAML.load_file(Rails.root.join('config/mongoid.yml'))[Rails.env]['database'] # Configure to use ImageMagick, Rails defaults, and the Mongo data store app.configure_with(:imagemagick) app.configure_with(:rails) do |c| c.datastore = Dragonfly::DataStorage::MongoDataStore.new :database => db end # 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 # ... end See {file:Models} for more info.
Version data entries
9 entries across 9 versions & 3 rubygems