Sha256: 6cd59af221ce402220ffb6125bb4a48322c9b45f03c884c3ddfe2877ce9e7dc5

Contents?: true

Size: 1.64 KB

Versions: 60

Compression:

Stored size: 1.64 KB

Contents

CouchDB
=====
Dragonfly can be used with any ActiveModel-compatible model, and so you can use it with CouchDB using [CouchRest::Model](https://github.com/couchrest/couchrest_model).

Since CouchDB allows you to store files directly on documents as attachments, you can also use the supplied {Dragonfly::DataStorage::CouchDataStore CouchDataStore}.
which allows storing files as attachments directly on documents.

For more info about ActiveModel, see {file:Models}.

For more info about using the Couch data store, see {file:DataStorage}.

Example setup in Rails, using CouchRest::Model
-------------------------------------
In config/initializers/dragonfly.rb:

    require 'dragonfly'

    app = Dragonfly[:images]

    # Get database config from config/couchdb.yml
    couch_settings = YAML.load_file(Rails.root.join('config/couchdb.yml'))[Rails.env]

    # Configure to use ImageMagick, Rails defaults, and the Couch data store
    app.configure_with(:imagemagick)
    app.configure_with(:rails) do |c|
      c.datastore = Dragonfly::DataStorage::CouchDataStore.new(
        :host => couch_settings['host'],
        :port => couch_settings['port'],
        :username => couch_settings['username'],
        :password => couch_settings['password'],
        :database => couch_settings['database']
      )
    end

    # Allow all CouchRest::Model models to use the macro 'image_accessor'
    app.define_macro(CouchRest::Model::Base, :image_accessor)

    # ... any other setup, see Rails docs

Then in models:

    class Album < CouchRest::Model::Base
      property :cover_image_uid
      image_accessor :cover_image

      # ...
    end

See {file:Models} for more info.

Version data entries

60 entries across 60 versions & 3 rubygems

Version Path
classiccms-0.3.7 vendor/bundle/gems/dragonfly-0.9.12/extra_docs/Couch.md
classiccms-0.3.6 vendor/bundle/gems/dragonfly-0.9.12/extra_docs/Couch.md
classiccms-0.3.5 vendor/bundle/gems/dragonfly-0.9.12/extra_docs/Couch.md
classiccms-0.3.4 vendor/bundle/gems/dragonfly-0.9.12/extra_docs/Couch.md
classiccms-0.3.3 vendor/bundle/gems/dragonfly-0.9.12/extra_docs/Couch.md
classiccms-0.3.2 vendor/bundle/gems/dragonfly-0.9.12/extra_docs/Couch.md
classiccms-0.3.1 vendor/bundle/gems/dragonfly-0.9.12/extra_docs/Couch.md
classiccms-0.3.0 vendor/bundle/gems/dragonfly-0.9.12/extra_docs/Couch.md
dragonfly-0.9.12 extra_docs/Couch.md
dragonfly-0.9.11 extra_docs/Couch.md
dragonfly-0.9.10 extra_docs/Couch.md
dragonfly-0.9.9 extra_docs/Couch.md
dragonfly-0.9.8 extra_docs/Couch.md
dragonfly-0.9.5 extra_docs/Couch.md
dragonfly-0.9.4 extra_docs/Couch.md
dragonfly-0.9.3 extra_docs/Couch.md
dragonfly-0.9.2 extra_docs/Couch.md
dragonfly-0.9.1 extra_docs/Couch.md
dragonfly-0.9.0 extra_docs/Couch.md
oahu-dragonfly-0.8.2 extra_docs/Couch.md