title: Rails 6 Autoload Not Finding Class
body: <p>I'm attempting to upgrade from Rails 5 to 6. I did the upgrade steps including adding this:</p>
  
  <pre><code># config/application.rb
  config.load_defaults 6.0
  </code></pre>
  
  <p>I have this class:</p>
  
  <pre><code># lib/notification/auto_thank.rb
  module Notification
    class AutoThank
      def perform
        # stuff
      end
    end
  end
  </code></pre>
  
  <p>Which is used in a task:</p>
  
  <pre><code>namespace :notify do
    task auto_thank: :environment do
      Notification::AutoThank.new.perform
    end
  end
  </code></pre>
  
  <p>When I do <code>puts config.autoload_paths</code>, it's listed, so I expect it to autoload:</p>
  
  <p><code>/my/app/path/lib/notification/auto_thank.rb</code></p>
  
  <p>But when I run the task I get an error:</p>
  
  <blockquote>
    <p>NameError: uninitialized constant Notification</p>
  </blockquote>
  
  <p>It gets stranger. When I add a require to the task:</p>
  
  <pre><code>task auto_thank: :environment do
    require '/my/app/path/lib/notification/auto_thank.rb'
    Notification::AutoThank.new.perform
  end
  </code></pre>
  
  <p>I get a different error:</p>
  
  <blockquote>
    <p>NameError: expected file /my/app/path/lib/notification/auto_thank.rb to define constant AutoThank, but didn't</p>
  </blockquote>
  
  <p>What am I missing?</p>