Skip to content

Instantly share code, notes, and snippets.

@dinks
Created May 17, 2015 19:20
Show Gist options
  • Save dinks/22ec4bcf511defab3745 to your computer and use it in GitHub Desktop.
Save dinks/22ec4bcf511defab3745 to your computer and use it in GitHub Desktop.
Autoload pitfalls
# qux.rb
Qux = "I'm at the root!"
# foo.rb
module Foo
end
# foo/qux.rb
module Foo
Qux = "I'm in Foo!"
end
# foo/bar.rb
class Foo::Bar
def self.print_qux
puts Qux
end
end
# Ruby
"I'm at the root!"
# Rails, because of autoloading
"I'm in Foo!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment