# On Modules and require in general / on ActiveSupport in par

**URL:** <https://www.ruby-forum.com/t/on-modules-and-require-in-general-on-activesupport-in-par/78004>\
**Category:** Ruby\
**Created:** [December 2, 2006, 5:31pm UTC](https://www.ruby-forum.com/t/on-modules-and-require-in-general-on-activesupport-in-par/78004 "2006-12-02T17:31:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![niconoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a87d85/32.png) [@niconoe](https://www.ruby-forum.com/u/niconoe)\
**Post date:** [December 2, 2006, 5:31pm UTC](https://www.ruby-forum.com/t/on-modules-and-require-in-general-on-activesupport-in-par/78004/1 "2006-12-02T17:31:37Z")

</div>

I dont get how :

-\> I require\_gem ActiveSupport and it’s not loading any ActiveSupport  
module  
-\> I require\_gem Rails and it’s loading  
ActiveSupport module…

Any clue appreciated.

Here is a transcript of my irb session  
#initial state  
require ‘rubygems’  
=\> true  
a = Module.constant

# I load a gem, the Modules gets loaded

require\_gem ‘needle’  
=\> true  
b = Module.constant  
b - a  
=\> [“Queue”, “Needle”, “Mutex”, “ScanError”, “Logger”, “StringScanner”,  
“SizedQueue”, “Monitor”, “MonitorMixin”, “ConditionVariable”]

# I load ActiveSupport, nothing gets loaded !!!

require\_gem ‘activesupport’  
=\> true  
c = Module.constant  
c -b  
=\> []

# I load Rails, ActiveSupport is loaded. where is th magic going on ?

require\_gem ‘rails’  
=\>true  
d = Module.constant  
(d - c).find\_all { |t| t.downcase.include?(“active”)}  
=\> [“ActiveSupport”, “ActiveRecord”]

---

<div class="post-metadata">

**Author:** ![niconoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a87d85/32.png) [@niconoe](https://www.ruby-forum.com/u/niconoe)\
**Post date:** [December 4, 2006, 3:26am UTC](https://www.ruby-forum.com/t/on-modules-and-require-in-general-on-activesupport-in-par/78004/2 "2006-12-04T03:26:07Z")

</div>

On 12/3/06, nrolland [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #initial state  
> require ‘rubygems’  
> =\> true  
> a = Module.constant

Hmmm, I’m not sure where you got #constant from… it’s usually  
#constants .

> # I load ActiveSupport, nothing gets loaded !!!
> 
> require\_gem ‘activesupport’  
> =\> true  
> c = Module.constant  
> c -b  
> =\> []

AFAIK, #require\_gem isn’t normally used anymore. What it does is add  
the gem directory to the load path, and then require all its  
“autorequires”. Problem is, activesupport doesn’t specify any  
autorequires, so it doesn’t do anything.

I believe usually, you just “require ‘rubygems’”, and then require  
files in any gems as you need them. In activesupport’s case, you want  
the file named ‘active\_support.rb’. So this should do the trick:

require ‘rubygems’  
require ‘active\_support’

Even more commonly, requiring rubygems is done through the RUBYOPT  
environment variable (set it to ‘rubygems’), and not in the code  
itself. This way, you don’t rely on the library being provided  
through a gem.

> (d - c).find\_all { |t| t.downcase.include?(“active”)}  
> =\> [“ActiveSupport”, “ActiveRecord”]

Shorter:

(d - c).grep(/active/i)

🙂
