This is 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:
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:
You may pass
:filename => 'some_filename.png' to
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.
- Fork it ( https://github.com/katafrakt/carrierwave-nobrainer/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request