This project is retired. See the official one.
This is was a NoBrainer adapter for CarrierWave gem.
Please note: This version targets CarrierWave's master branch, which is under development. Expect bugs! (But also some nice features, like arrays of files).
Add this line to your application's Gemfile:
gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'
gem 'carrierwave-nobrainer', github: 'katafrakt/carrierwave-nobrainer'
And then execute:
$ bundle
In your model put include CarrierWave::NoBrainer
and then follow normal CarrierWave
procedure. For example:
class User
include NoBrainer::Document
include NoBrainer::Document::Timestamps
include CarrierWave::NoBrainer
field :name, type: String, required: true
field :avatar, type: String
mount_uploader :avatar, AvatarUploader
end
Unlike ActiveRecord version, CarrierWave's methods are not included automatically to every NoBrainer model. This is because I believe that explicit is better than implicit. If you are not with me, you can add this to your initializer:
NoBrainer::Document.send(:include, CarrierWave::NoBrainer)
You may pass :filename => 'some_filename.png'
to
the mount_uploader
method options. For example:
mount_uploader :icon, SomeUploader, :filename => 'icon.png'
This will have the effect of not storing this static filename in the document to avoid polluting the DB with useless fields.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)