carrierwave_backgrounder icon indicating copy to clipboard operation
carrierwave_backgrounder copied to clipboard

NameError (uninitialized constant CarrierWave::Workers::ProcessAssetMixin):

Open thekevinscott opened this issue 9 years ago • 5 comments

Hi,

I'm trying to work with ActiveJob and getting this error:

NameError (uninitialized constant CarrierWave::Workers::ProcessAssetMixin):
  app/jobs/process_image_job.rb:2:in `<class:ImageProcessJob>'
  app/jobs/process_image_job.rb:1:in `<top (required)>'
  app/models/user.rb:69:in `<class:User>'
  app/models/user.rb:26:in `<top (required)>'
  app/controllers/users_controller.rb:42:in `set_user'

I've looked at piotrkaczmarek's repo which works fine for me, so it's definitely something on my end, but I'm not sure how to debug.

Relevant code:

models/user.rb

class User < ActiveRecord::Base
...
  mount_uploader :cover_photo, ImageUploader
  process_in_background :cover_photo, ProcessImageJob
...
end

jobs/process_image_job.rb

class ProcessImageJob < ActiveJob::Base
  include ::CarrierWave::Workers::ProcessAssetMixin
end

uploaders/image_uploader.rb

class ImageUploader < CarrierWave::Uploader::Base
  storage: fog

  version :mobile do
    process resize_to_limit: [380, nil]
  end
  ...  
end

application.rb

config.active_job.queue_adapter = :delayed_job

carrierwave_backgrounder.rb

CarrierWave::Backgrounder.configure do |c|
  c.backend :active_job, queue: :carrierwave
end

Gemfile

...
gem "carrierwave", "~> 0.10.0"
gem "carrierwave_backgrounder", "~> 0.4.2"
gem "mini_magick"
...

When I switch things to sidekiq locally, it processes the images fine. I'm just not really sure how to debug this any further.

thekevinscott avatar Jan 18 '16 15:01 thekevinscott

It seems missing source in gem.

ls `bundle show carrierwave_backgrounder`/lib/backgrounder/workers

It worked for me

gem 'carrierwave_backgrounder', github: 'lardawge/carrierwave_backgrounder'

benridane avatar Feb 02 '16 08:02 benridane

I run into the same problem as @scottlabs when i specify gem 'carrierwave_backgrounder' in my Gemfile. However, if I specify gem 'carrierwave_backgrounder', github: 'lardawge/carrierwave_backgrounder', then it works fine.

@scottlabs I also noticed that you don't include ::CarrierWave::Backgrounder::Delay in uploaders/image_uploader.rb, which you should per the example.

kevinsapp avatar Feb 02 '16 12:02 kevinsapp

@benridane @kevinsapp Thanks to both of you, updating to using the Github path resolves this error for me.

I'm not that familiar with the Rails gem ecosystem - does having to specify the github path imply an actual issue, or just something specific to my environment? I.e., should I close this issue or leave it open?

thekevinscott avatar Feb 02 '16 15:02 thekevinscott

I am facing the same issue. Even though I have :git => 'https://github.com/lardawge/carrierwave_backgrounder.git'

joshirashmics avatar Jun 09 '17 03:06 joshirashmics

To anybody who hasn't read this, you're getting this error because while the master branch of this repo is being updated, no new version since 0.4.2, released in August 2015, has been released to rubygems.

As of this post, 0.4.2, which does not have the ::CarrierWave::Workers::ProcessAssetMixin mixin, is the most recent published release: https://rubygems.org/gems/carrierwave_backgrounder.

EverybodyKurts avatar Sep 28 '17 17:09 EverybodyKurts

Released 0.4.3 and am working to a 1.0 release. Branch for 1.0 is up.

lardawge avatar Aug 09 '23 16:08 lardawge