Git Product home page Git Product logo

carrierwave-nobrainer's Introduction

NoBrainer CarrierWave Adapter

carrierwave-nobrainer is an adapter to make CarrierWave work nicely with NoBrainer.

Installation

Include in your Gemfile:

gem 'carrierwave', '>= 2', '< 3'
gem 'carrierwave-nobrainer'

Note: this adapter has only been tested with the master branch of carrierwave, not the 0.10.0 version from Feb. 2014.

Usage

Use carrierwave as usual.

As an added feature, 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.

Storing files in RethinkDB

In the case you need to store files in the RethinkDB database, this gem also add a Carrierwave storage for NoBrainer.

To use it, in your uploader set the storage to :nobrainer

class AvatarUploader < CarrierWave::Uploader::Base
  storage :nobrainer
end

License

MIT license.

carrierwave-nobrainer's People

Contributors

zedtux avatar nviennot avatar

Stargazers

 avatar vish avatar Jeroen Visser avatar Jarosław Konik avatar

Watchers

 avatar  avatar James Cloos avatar

carrierwave-nobrainer's Issues

Issue with Rails 6

Hi,
Few months ago, when I used this gem she was working properly. But since the update of Nobrainer with the Rails 6 this gem don't work.
I would like to know if this gem need to be update for the Rails 6 and if it will be plan.
Thanks.
Regards.

Upload fails silently on update

I'm facing issues with uploader not being able to validate integrity via controller params
@user.update(user_params) will return true even though it's a google sheet

But testing on the console validation kicks in using File.new(filepath)

<ActionController::Parameters {"avatar"=>#<ActionDispatch::Http::UploadedFile:0x007ff2ffe6b5c8 @tempfile=#<Tempfile:/var/folders/1p/rq1xc3416d96js6v7k9f1j200000gn/T/RackMultipart20161101-12484-732zag.gsheet>, @original_filename="test.gsheet", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"test.gsheet\"\r\nContent-Type: application/octet-stream\r\n">} permitted: true>

let me know of any more details you'd need! Thank you

try to use carrierwave-base64 with nobrainer

Hi,
i would like adapt this gem with noBrainer https://github.com/y9v/carrierwave-base64 to upload a file in Base64.
So, i update this file https://github.com/y9v/carrierwave-base64/blob/master/lib/carrierwave/base64/railtie.rb
and here we can see what has been changed

module Carrierwave
  module Base64
    # Railtie class to load the carrierwave-base64 adapters
    # Loads adapters for ActiveRecord and Mongoid
    class Railtie < Rails::Railtie
      ActiveSupport.on_load :active_record do
        ActiveRecord::Base.extend Carrierwave::Base64::Adapter
      end

      ActiveSupport.on_load :mongoid do
        Mongoid::Document::ClassMethods.include Carrierwave::Base64::Adapter
      end

      ActiveSupport.on_load :nobrainer do
        puts("extending NoBrainer ...")
        NoBrainer::Document::ClassMethods.include Carrierwave::Base64::Adapter
      end
    end
  end
end

I have found ActiveSupport.onload :nobrainer when i use in console this command

irb(main):011:0> ActiveSupport.instance_variable_get(:@loaded).keys()
=> [:i18n, :after_initialize, :before_eager_load, :action_view, :active_record, :mongoid, :nobrainer, :action_controller, :before_configuration, :action_mailer, :before_initialize, :active_job, :action_dispatch_integration_test, :action_controller_base, :active_support_test_case, :action_cable, :action_cable_channel, :action_cable_connection, :action_controller_api, :devise_controller, :devise_failure_app]

and when I use

irb(main):016:0> ActiveSupport.instance_variable_get(:@loaded)[:nobrainer]
=> []

nobrainer doesn’t seem to be loaded.
Moreover, I’m using the classNoBrainer::Document::ClassMethods like it is used in https://github.com/nviennot/carrierwave-nobrainer/blob/master/lib/carrierwave-nobrainer.rb line 150.

When I start my server, I can’t see the puts message, and I have the error message “mount_base64_uploader not defined” like if ActiveSupport.on_load(:nobrainer) was not executed.

Am I missing something? Can you please help me?

Thanks for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.