A project I am working on uses a model named Process. This would normally override the ::Process module, but I've wrapped it in a namespace for this application to prevent that:
/app/models/flex_data/process.rb defines FlexData::Process
script/console log demonstrating the problem:
$ script/console
Loading development environment.
>> Dependencies.clear
=> nil
>> Object.const_defined? :Process
=> true
>> Object.const_defined? :FlexData
=> false
>> FlexData::Process
=> FlexData::Process
>> Object.const_defined? :FlexData
=> true
>> FlexData.const_defined? :Process
=> true
>> FlexData.const_get(:Process).class
=> Class
>> Object.const_get(:Process).class
=> Module
>> Dependencies.clear
=> nil
>> Object.const_defined? :Process
=> false
The relevant log entry for the second clear() call (Dependencies.log_activity = true):
Dependencies: called clear()
Dependencies: removing constant FlexData
Dependencies: removing constant Process
More to the point, this causes problems with any controller that uses FlexData::Process (or anything else that would collide with the base global namespace.) The first load is successful, but the second fails with a LoadError. I have pasted the full log at http://pastie.caboo.se/11915 In particular see the logging .diff I'm using for additional debug information in Dependencies.load_missing_constant (attached)
The first request:
Dependencies: loading script/../config/../app/models/flex_data/process.rb defined Process, FlexData::Process
Dependencies: FlexData tried to load Process (FlexData::Process) from script/../config/../app/models/flex_data/process.rb: true
The second request:
Dependencies: loading script/../config/../app/models/flex_data/process.rb defined FlexData::Process
Dependencies: Object tried to load Process (Process) from script/../config/../app/models/flex_data/process.rb: false
LoadError (Expected script/../config/../app/models/flex_data/process.rb to define Process):
.//vendor/rails/activesupport/lib/active_support/dependencies.rb:236:in `load_missing_constant'