Shrine::Plugins::Mongoid

Provides Mongoid integration for Shrine.

Installation

gem "shrine-mongoid"

Usage

Shrine.plugin :mongoid
class Post
  include Mongoid::Document
  include ImageUploader[:image]

  field :image_data, type: String
end

This plugin will add validations and callbacks:

post = Post.new
post.image = file
post.image.storage_key #=> "cache"
post.save
post.image.storage_key #=> "store"
post.destroy
post.image.exists?     #=> false

If for some reason you don't want callbacks and/or validations, you can turn them off:

plugin :mongoid, callbacks: false, validations: false

Contributing

You can run the tests with the Rake task:

$ bundle exec rake test

License

MIT