While debugging an unrelated issue in rspec, I'm coming across issues with constant loading. The setup is as follows:
# app/models/foo.rb
class Foo << ApplicationRecord
include Foo::Searchable
end
# app/models/foo/searchable.rb
module Foo::Searchable
extend ActiveSupport::Concern
included do
#yada yada
end
end
I received the following error while debugging. NameError: uninitialized constant #<Class:0x00007fadd32ea580>::Searchable
Changing the naming to Foos::Searchable
with corresponding folder move does fix the issue but I would like to understand what is actually happening.
Rails 6.0.3.1 Ruby 2.6.6
This turns out to be caused by incompatibility with Byebug. Byebug stops the events Zeitwerk uses for autoloading to fire off in a debugging session. The issue is described here.
The <<
was a typo and would not result in that error.