Croplio
2010-Jul-25 15:09 UTC
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 :
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?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
