Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to use carrierwave-base64 with nobrainer #3

Open
arabakevin opened this issue Jul 15, 2020 · 0 comments
Open

try to use carrierwave-base64 with nobrainer #3

arabakevin opened this issue Jul 15, 2020 · 0 comments

Comments

@arabakevin
Copy link

arabakevin commented Jul 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant