# Don't understand :: in ActionController::Base

**URL:** <https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409>\
**Category:** Ruby\
**Created:** [July 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409 "2006-07-14T15:13:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409/1 "2006-07-14T15:13:18Z")

</div>

I understand the concept of classes and subclasses thanks to the  
excellent “Programming Ruby - The Pragmatic Programmer’s Guide”.  
However, I don’t understand what :: signify in terms of inheritance,  
parent and child in e.g.

ActionController::Base

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 14, 2006, 3:14pm UTC](https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409/2 "2006-07-14T15:14:56Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> I understand the concept of classes and subclasses thanks to the  
> excellent “Programming Ruby - The Pragmatic Programmer’s Guide”.  
> However, I don’t understand what :: signify in terms of inheritance,  
> parent and child in e.g.
> 
> ActionController::Base

Btw, I’m told that I can find the answer in chapter 9, starting at page  
117. But I read it on the web at  
[Programming Ruby: The Pragmatic Programmer's Guide](http://www.ruby-doc.org/docs/ProgrammingRuby/), so I have no chapters.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 14, 2006, 5:54pm UTC](https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409/3 "2006-07-14T17:54:32Z")

</div>

Hi PÃ¥l,  
I’m a newbie too. I’ll stick my neck out and answer here just so as to  
“trick” an expert into answering. Once they see my miserable excuse for  
an answer, they will be honor bound to correct me 🙂

ActionController::Base refers to the “Base” class of the Module  
ActionController. So you are not “inheriting” the whole module, just  
the “Base” class of the module. Makes sense for a Class to inherit a  
Class definition rather than a whole module’s definition.

best,  
jp

PÃ¥l BergstrÃ¶m wrote:

> PÃ¥l BergstrÃ¶m wrote:
> 
> > I understand the concept of classes and subclasses thanks to the  
> > excellent “Programming Ruby - The Pragmatic Programmer’s Guide”.  
> > However, I don’t understand what :: signify in terms of inheritance,  
> > parent and child in e.g.
> > 
> > ActionController::Base
> 
> Btw, I’m told that I can find the answer in chapter 9, starting at page  
> 117. But I read it on the web at  
> [Programming Ruby: The Pragmatic Programmer's Guide](http://www.ruby-doc.org/docs/ProgrammingRuby/), so I have no chapters.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 14, 2006, 8:08pm UTC](https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409/4 "2006-07-14T20:08:11Z")

</div>

On Jul 14, 2006, at 9:13 AM, Pål Bergström wrote:

> I understand the concept of classes and subclasses thanks to the  
> excellent “Programming Ruby - The Pragmatic Programmer’s Guide”.  
> However, I don’t understand what :: signify in terms of inheritance,  
> parent and child in e.g.

This seems to be a common source of confusion when learning Ruby  
(myself included).

It is really pretty simple. Class and Module objects are referenced  
via hierarchical names:

```
A
A::B
ActionController::Base
ActiveRecord::Base
Process::Sys

```

The confusion arises when you assume that the names imply class/subclass  
relationships. The hierarchy of _names_ is 100% independent of the  
hierarchy of classes.

The scope operator (:🙂 provides the syntax for constructing the  
hierarchical class names but has no impact on the inheritance  
structure of the classes:

class A  
class A1; end  
end

class B  
class B1; end  
end

class C \< A; end  
class D \< A::A1; end  
class E \< B::B1; end  
class B::B1::B2 \< A::A1; end  
class A::A1::A2 \< B::B1::B2; end

From those definitions you get the following inheritance structure:

Object + – A --------- C  
|  
+ – A::A1 --±- D  
| |  
| ±- B::B1::B2 – A::A1::A2  
|  
+ – B  
|  
+ – B::B1 ----- E

The associated naming hierarchy is

top + – A – A1 – A2  
|  
+ – B – B1 – B2  
|  
+ – C  
|  
+ – D  
|  
+ – E

Gary W.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 14, 2006, 9:15pm UTC](https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409/5 "2006-07-14T21:15:37Z")

</div>

Jeff P. wrote:

> Hi PÃ¥l,  
> I’m a newbie too. I’ll stick my neck out and answer here just so as to  
> “trick” an expert into answering. Once they see my miserable excuse for  
> an answer, they will be honor bound to correct me 🙂
> 
> ActionController::Base refers to the “Base” class of the Module  
> ActionController. So you are not “inheriting” the whole module, just  
> the “Base” class of the module. Makes sense for a Class to inherit a  
> Class definition rather than a whole module’s definition.

Thanks for the effort Jeff. A good trick 🙂

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 14, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409/6 "2006-07-14T21:19:02Z")

</div>

unknown wrote:

> The confusion arises when you assume that the names imply class/subclass  
> relationships. The hierarchy of _names_ is 100% independent of the  
> hierarchy of classes.  
> class D \< A::A1; end  
> class E \< B::B1; end  
> class B::B1::B2 \< A::A1; end  
> class A::A1::A2 \< B::B1::B2; end
> 
> From those definitions you get the following inheritance structure:
> 
> Object + – A --------- C  
> |  
> + – A::A1 --±- D  
> | |  
> | ±- B::B1::B2 – A::A1::A2  
> |  
> + – B  
> |  
> + – B::B1 ----- E

Thanks. That helped.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 14, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/dont-understand-in-actioncontroller-base/98409/7 "2006-07-14T19:17:56Z")

</div>

On Jul 14, 2006, at 11:54 AM, Jeff P. wrote:

> Class definition rather than a whole module’s definition.
> 
> best,  
> jp

Everything but sentence was perfect. You can’t inherit modules.

(Please avoid top posting in the future).
