Sha256: ff4e94aafa2a146b5666eb1e44ac41380d5a1cf2b71fbb0037bb92172af09a6e
Contents?: true
Size: 1.36 KB
Versions: 7
Compression:
Stored size: 1.36 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 RMagick, Rails defaults, and the Mongo data store app.configure_with(:rmagick) 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
7 entries across 7 versions & 1 rubygems