NoBrainerORM / nobrainer

Ruby ORM for RethinkDB
http://nobrainer.io/
Other
387 stars 49 forks source link

try to use carrierwave-base64 with nobrainer #262

Closed arabakevin closed 3 years ago

arabakevin commented 4 years ago

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.

arabakevin commented 4 years ago

i have created an other ticket https://github.com/nviennot/carrierwave-nobrainer/issues/3. Thanks.

zedtux commented 3 years ago

Closing this issue as it relates to the carrierewave-nobrainer gem.