The Definition Of Nested Module

Nested modules are not what they seem. In this post, Rishi talks about the scope among nested variables. Here’s an Ah-ha! moment for you!

Rishi's avatarLearning shall never stop..!!!

When we define nested modules like this:

and when we do like this:

Even though both method calls to print_const looks same, and should return same result. But it returns different values of the constant.

Reason:
When you do this in first case:

and this gives:

So ruby looks for the constant X in the order as A::B::C, A::B, A. and it loads wherever it finds first, and as in our scenario, under module B.

And in second scenario:

and this gives:

Here since the nesting of the module is different, it only search in A::B::C and A, skipping A::B. So it finds constant X under module A.

View original post

Pro-tips for production server setup (when shit hits the roof)

This post is not related to production deployment automation. This post is our voice of experience (read as: major issues caused due by "minor" missing server configurations) and how we resolved them. These are changes that would help you in case you are dealing with Upgrading your server stack that uses HAProxy and SSL (We were using EngineYard)! … Continue reading Pro-tips for production server setup (when shit hits the roof)