Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/spohlenz/as-autoload

Demonstration of bug in ActiveSupport::Dependencies
https://github.com/spohlenz/as-autoload

Last synced: 28 days ago
JSON representation

Demonstration of bug in ActiveSupport::Dependencies

Awesome Lists containing this project

README

        

Demonstration of autoloading issue in ActiveSupport::Dependencies.
Edit Gemfile to switch between patched and unpatched versions of ActiveSupport.

# Simple case: load class within first folder
# #
puts Blog::Post.new.inspect

# Another simple case: load nested class within folders
# #
puts Blog::Admin::PostsController.hardcoded.inspect

# It gets complicated: attempts to load Blog::Admin::Post (similar to inherited_resources)
# We would expect either a NameError or have it return Blog::Post. Instead we get:
# /Users/sam/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-12786518f1f7/
# activesupport/lib/active_support/dependencies.rb:476:in `load_missing_constant':
# Blog is not missing constant Post! (ArgumentError)
puts Blog::Admin::PostsController.autodetect.inspect

# Interestingly, this last line works if we run it first (before Blog::Post is loaded)
# but then fails if we run it again (since Blog::Post is now loaded).