You can't set a constant with namespace in the initializers?

Help! in my rails controllers, there is a ‘Admin’ namespace. (My the
structure of the controllers dir is like this :


The ‘Admin’ will automatically become a Module constant (I know it
from the console: ‘puts Admin => Module’);

And in my initializers, ther is a init.rb which has codes like this:

Object.const_set(‘A’, ‘a’)
Object::Admin.const_set(‘B’, 'b)

Then I run the console:

puts Object::A
“a” #just fine
=> nil

puts Object::Admin::B
NameError: uninitialized constant Admin::B # What’s wrong?

Why diffrent results? Who can help me to make the Admin::B part works?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs