On Apr 10, 2008, at 10:32 , Frederick Cheung wrote:

> On 9 Apr 2008, at 22:16, Xavier Noria wrote:
>
>>
>> On Apr 9, 2008, at 22:04 , Frederick Cheung wrote:
>>
>>> I've a module SecuritySystem::SecretsProxy.
>>> SecuritySystem::SecretsProxy::AnyConstant evaluates to AnyConstant
>>> (as
>>> long as AnyConstant is something Dependencies can load but is not
>>> loaded yet), even though AnyConstant isn't defined at that level.  
>>> The
>>> second time you evaluate SecuritySystem::SecretsProxy::AnyConstant
>>> then you get a NameError as I expected to get in the first place.
>>
>> From the description I am not sure I understand the setup. Frederick
>> would you please send a minimal example to be able to reproduce it?
>
>
> Sure. From an empty rails app (or not), create in
> lib/any_constant.rb:
> class AnyConstant
> end
> in lib/my_lib/my_module.rb
> module MyLib
>   module MyModule
>   end
> end
>
> Now from script/console:
>
>>> MyLib::MyModule::AnyConstant
> => AnyConstant
> but try it a second time
>>> MyLib::MyModule::AnyConstant
> NameError: uninitialized constant MyLib::MyModule::AnyConstant
>       from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
> active_support/dependencies.rb:266:in `load_missing_constant'
>       from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
> active_support/dependencies.rb:453:in `const_missing'
>       from (irb):3
>

Thank you!

This smells like a bug to me. From what I remember the intention of  
the implementation of dependencies.rb is to create intermediate  
modules as needed, and dynamically put the constants where they belong.

So (talking from memory) I'd expect the first const_missing to fail.  
I'll have a llok at it it.

-- fxn


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to