Ruby (and Rails) nested module syntax
- by brad
I'm wondering what the difference is between the following two modules
# First Example
module Parent
module Child
end
end
and
# Second Example
module Parent::Child
end
Using the 2nd method, it appears as though the Parent module must be previously defined, otherwise I get an 'uninitialized constant' error
Given this, what is the preferred way of defining modules such as this and then adding nested children with regards to syntax and file structure (ie. folders etc). Reference to a Rails way would be greatly appreciated.
Are these two examples for all intents and purposes equivalent?