NoBrainer adapter for CarrierWave
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/carrierwave
spec
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
carrierwave-nobrainer.gemspec

README.md

CarrierWave::NoBrainer

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).

Installation

Add this line to your application's Gemfile:

gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'
gem 'carrierwave-nobrainer', github: 'katafrakt/carrierwave-nobrainer'

And then execute:

$ bundle

Usage

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)

Added features

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.

Contributing

  1. Fork it ( https://github.com/katafrakt/carrierwave-nobrainer/fork )
  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 a new Pull Request