Add this line to your application's Gemfile:
gem 'refile-mongoid'
And then execute:
$ bundle
Or install it yourself as:
$ gem install refile-mongoid
Se original Refile documentation for usage.
You just do not need to create a database migration as attachment id field is defined automatically on the model.
Because storing/deleting of files is triggered by callbacks,
you might want to specify cascade_callbacks: true
for your embedded associations e.g:
class Photo
include Mongoid::Document
attachment :image
end
class Album
include Mongoid::Document
embeds_many :photos, cascade_callbacks: true
end
See MongoID doc
$ rake