dragonfly-activerecord

Gem Version Build Status Dependency Status Code Climate

Provides a data store for Dragonfly, backed by ActiveRecord.

Requires a Rails application using Dragonfly 1.0+.

Why?

Because there's a fat chance our app already has a database. Why bother with S3 when your DB can do the job just fine?

Yes, storing files in a relational database may be a bad idea at scale, but for many use cases (up to a few gigabytes of storage) it really eases the maintenance burden.

Installation

Add this line to your application's Gemfile:

gem 'dragonfly-activerecord'

Create a migration:

$ rails generate migration add_dragonfly_storage

Edit the migration file:

require 'dragonfly-activerecord/migration'

class AddDragonflyStorage < ActiveRecord::Migration
  include Dragonfly::ActiveRecord::Migration
end

Run the migration:

$ rake db:migrate

Configure Dragonfly itself (in config/initializers/dragonfly.rb, typically):

require 'dragonfly-activerecord/store'

Dragonfly.app.configure do
  # ... your existing configuration here
  datastore Storage::DataStore.new
end

... and you're good to go!

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request