[Rails] 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home