Created
July 15, 2012 18:52
-
-
Save mitchellh/3118148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONSTANT = "in <global>" | |
class Foo | |
CONSTANT = "in foo" | |
end | |
class Foo::Bar | |
puts CONSTANT # => "in <global>" | |
end | |
class Foo | |
class Bar | |
puts CONSTANT # => "in foo" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This quite often bites when developing namespaced engines for Rails, e.g:
It can get especially tricky when in development mode and constant autoloading is in effect - you end having to use
require_dependency
to make sure that the constant you need is loaded properly.