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

**URL:** <https://www.ruby-forum.com/t/you-cant-set-a-constant-with-namespace-in-the-initializers/192179>\
**Category:** Rails\
**Created:** [July 25, 2010, 7:33pm UTC](https://www.ruby-forum.com/t/you-cant-set-a-constant-with-namespace-in-the-initializers/192179 "2010-07-25T19:33:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctwise](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@ctwise](https://www.ruby-forum.com/u/ctwise)\
**Post date:** [July 25, 2010, 7:33pm UTC](https://www.ruby-forum.com/t/you-cant-set-a-constant-with-namespace-in-the-initializers/192179/1 "2010-07-25T19:33:08Z")

</div>

Help! in my rails controllers, there is a ‘Admin’ namespace. (My the  
structure of the controllers dir is like this :  
app/controllers:  
home\_controller.rb  
…  
admin/posts\_controller.rb  
admin/pages\_controller.rb

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?
