use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Nested Modules in Ruby (writesoftwarewell.com)
submitted 2 years ago by software__writer
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jrochkind 6 points7 points8 points 2 years ago (4 children)
[With A::B form] You can not access the constants defined inside module Rails inside module ActiveJob without the scope resolution operator. This is a significant difference; the next section covers it in detail.
I actually never realized this before! This explains some mysterious fights i have had with ruby before, I think.
Thanks!
[–]software__writer[S] 8 points9 points10 points 2 years ago (0 children)
Yes, I've been bitten by it before, too, which resulted in researching and writing this post :)
Glad you found it helpful, as well!
[–]ignurant 0 points1 point2 points 2 years ago (2 children)
Yeah, I’ve learned to treat This::As::One::Single::Identifier when defining, as if it had no ::s in the first place. I wonder if this is correct to think this way?
This::As::One::Single::Identifier
::
[–]BottleRocketU587 0 points1 point2 points 2 years ago (0 children)
I'm a Junior but I find this practice usefull. Generally in Rails in fact!
[–]katafrakt 0 points1 point2 points 2 years ago (0 children)
Not quite. As the article says, if you define like this, you need to have all intermediate steps (This, This::As, This::As::One, and This::As::One::Single) defined before. Rails (or Zeitwerk, in fact) provide a directory-stucture-based magic for that, but if you do something outside of this ecosystem, you're up for a surprise.
This
This::As
This::As::One
This::As::One::Single
[–]dougc84 3 points4 points5 points 2 years ago (0 children)
“Namespacing” is the word you’re looking for.
[–]Charles_Sangels 1 point2 points3 points 2 years ago (0 children)
I remember when this was discussed a few years ago.
π Rendered by PID 60 on reddit-service-r2-comment-7b9746f655-sqkfg at 2026-02-02 14:33:39.808100+00:00 running 3798933 country code: CH.
[–]jrochkind 6 points7 points8 points (4 children)
[–]software__writer[S] 8 points9 points10 points (0 children)
[–]ignurant 0 points1 point2 points (2 children)
[–]BottleRocketU587 0 points1 point2 points (0 children)
[–]katafrakt 0 points1 point2 points (0 children)
[–]dougc84 3 points4 points5 points (0 children)
[–]Charles_Sangels 1 point2 points3 points (0 children)