Last Updated: February 25, 2016
·
467
· dinks

Autoload ruby

Q = 'Outer'

module Foo
  Q = 'Inner'
end

module Foo
  module Bar
    def self.t1
      puts Q
    end
  end
end

module Foo::Bar
  def self.t2
    puts Q
  end
end

Foo::Bar.t1 #=> Inner
Foo::Bar.t2 #=> Outer

This is because of Module.nesting Post http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/

This can be solved with autoload in Rails