title: Ruby on Rails: Get nested modules?
body: <p>In my Rails project I want to get all modules that are nested inside the module <code>A</code>.</p>
  
  <p>The file lib/assets/a/b.rb, consists of:</p>
  
  <pre><code>module A
    module B
    end
  end
  </code></pre>
  
  <p>In the Rails console:</p>
  
  <pre><code>A.constants
    =&gt; []
  A::B.class
    =&gt; Module
  A.constants
    =&gt; [:B]
  </code></pre>
  
  <p>Why is the first line returning an empty array, and how do I get round the problem?</p>