title: NameError uninitialized constant MyWorker::MyController
body: <p>I'm using sidekiq to do a simple sample worker. When a make a request to my endpoint, it finished successfully but in the worker I got the following error:</p>
  <pre><code>*** NameError Exception: uninitialized constant SaveMessageWorker::Message
  </code></pre>
  <p>I'm using:</p>
  <ul>
  <li>ruby 2.5.7</li>
  <li>rails 5.2.3</li>
  <li>sidekiq 6.0.0</li>
  </ul>
  <p>This is part of my api rails project structure:</p>
  <pre><code>app
  ---controllers
  ------api
  ---------v1
  ------------messages_controller.rb
  ---workers
  ------save_message_worker.rb
  config
  ---initializers
  ------sidekiq.rb
  ---application.rb
  </code></pre>
  <p>These are my files and paths:</p>
  <p><strong>app/workers/save_message_worker.rb</strong></p>
  <pre><code>class SaveMessageWorker
    include Sidekiq::Worker
  
    def perform(message_list)
      # byebug
      # When I tried the below line, I got: *** NameError Exception: uninitialized constant SaveMessageWorker::Message
      message = Message.new(message: message_list)
  
    end
  end
  </code></pre>
  <p><strong>app/controllers/api/v1/messages_controller.rb</strong></p>
  <pre><code>    def multiple_concurrent_workers
          begin
  
              SaveMessageWorker.perform_async(&quot;Hello World!&quot;)
              return (render json: {status: &quot;success&quot;, data:&quot;processed successfully&quot;})
  
          rescue =&gt; exception
              logger.error CONTROLLER_NAME + ': An error happened in method multiple_concurrent_workers: ' + exception.to_json
              return (render json: {status: &quot;error&quot;, message: exception})
          end
      end
  </code></pre>
  <p><strong>config/routes.rb</strong></p>
  <pre><code>Rails.application.routes.draw do
    require 'sidekiq/web'
    mount Sidekiq::Web =&gt; '/sidekiq'
    
    devise_for :users 
      namespace :api, defaults: { format: &quot;json&quot; } do
        namespace :v1 do
  
            resources :messages do
              collection do
                post :multiple_concurrent_workers
              end
            end
  
        end
      end
  
  end
  </code></pre>
  <p><strong>config/initializers/sidekiq.rb</strong></p>
  <pre><code>Sidekiq.configure_server do |config|
    config.redis = { url: 'redis://' + Rails.application.credentials[Rails.env.to_sym][:redis][:host].to_s + ':' +Rails.application.credentials[Rails.env.to_sym][:redis][:port].to_s + '/' + Rails.application.credentials[Rails.env.to_sym][:redis][:database].to_s }
  end
  
  Sidekiq.configure_client do |config|
    config.redis = { url: 'redis://' + Rails.application.credentials[Rails.env.to_sym][:redis][:host].to_s + ':' +Rails.application.credentials[Rails.env.to_sym][:redis][:port].to_s + '/' + Rails.application.credentials[Rails.env.to_sym][:redis][:database].to_s }
  end
  </code></pre>
  <p><strong>config/application.rb</strong></p>
  <pre><code>require_relative 'boot'
  
  require &quot;rails&quot;
  require &quot;active_model/railtie&quot;
  require &quot;active_job/railtie&quot;
  require &quot;active_record/railtie&quot;
  require &quot;active_storage/engine&quot;
  require &quot;action_controller/railtie&quot;
  require &quot;action_mailer/railtie&quot;
  require &quot;action_view/railtie&quot;
  require &quot;action_cable/engine&quot;
  require &quot;rails/test_unit/railtie&quot;
  
  Bundler.require(*Rails.groups)
  
  module IbeenDev
    class Application &lt; Rails::Application
      config.load_defaults 5.2
      
      config.middleware.use Rack::MethodOverride
      config.middleware.use ActionDispatch::Cookies
      config.middleware.use ActionDispatch::Session::CookieStore
      config.middleware.use ActionDispatch::Flash
      config.log_level = :error
      
      config.autoload_paths &lt;&lt; Rails.root.join(&quot;lib&quot;)
      config.eager_load_paths &lt;&lt; Rails.root.join(&quot;lib&quot;)
  
      config.api_only = true
      Koala.config.api_version = 'v2.0'
  
      config.active_job.queue_adapter = :sidekiq
  
    end
  end
  
  </code></pre>
  <p>There was an opened issued in the github project, but <a href="https://github.com/mperham/sidekiq/issues/3779#issuecomment-370664321" rel="nofollow noreferrer">author</a> said that this is not an exactly sidekiq problem.</p>
  <p>Can anyone help me to find the solution? Any help will be appreciated</p>