Search code examples
ruby-on-railsrubysidekiqrails-activestorage

Rails ActiveStorage File not found in sidekiq task


I have image in my project with ActiveStorage.attach

if params[:avatar]
  authorize! :update, current_user
  type, base64_image = Utils::Attach.type_and_base64(params[:avatar], 'avatar')
  current_user.avatar.attach(io: StringIO.new(base64_image), filename: "#{current_user.id}-#{Time.current.to_i}", content_type: type)
  current_user.save!
end

And it actually work good. But after I add sidekiq for mailer I started saw errorsidekiqscreenshot

This error adds after attach avatar. ActiveStorage::Blob


Solution

  • I don't found correct way to fix analyze job but monkey patching is work good for my case.

      module ActiveStorage::Blob::Analyzable
        def analyze_later
          analyze
        end
      end