We solved this in IRC, but the core issue is that there was a config.autoload_paths
glob set that was including models/**
as load paths.
Rails' auto-loader iterates the load paths, and tacks on the constant name. Once it finds a file that exists, it tries to load it, then throws an exception if the constant is not available.
So, what was happening is Rails had a list of load paths like:
/models/bar/
/models/
It was iterating the paths, and would find a match at /models/bar/foo.rb
, which it then loads (which makes Bar::Foo
available, but not Foo
), then throws the exception because Foo
isn't available.
The solution in this case was to remove the autoload_paths
setting, so that Rails would not find the wrong file to load for the root-level constant.