Skip to content

Loading…

fix remove_constant #8301

Closed
wants to merge 1 commit into from

3 participants

@danbob

I'm developing an app in edge rails and recently I've been getting the exceptions "A copy of Cms has been removed from the module tree but is still active!" and "Circular dependency detected while autoloading constant Cms::BaseController" whenever I made code changes (Cms is my controller namespace). I tracked the problem down to bff4d8d where a particular line of code was removed. Restoring this line fixes my issue.

As you can probably tell I know very little about the internals of rails, so I don't know if restoring this line causes problems elsewhere.

Daniel Arnfield fix remove_constant 7185607
@carlosantoniodasilva
Ruby on Rails member

/cc @fxn

@fxn
Ruby on Rails member

Hi @danbob, could you please upload a minimal app that reproduces the issue?

@danbob

Here: danbob/namespace_bug

Readme has the steps to reproduce the problem.

@fxn fxn closed this in 46ebce6
@fxn
Ruby on Rails member

Fixed, thanks for the minimal app!

@danbob

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 23, 2012
  1. fix remove_constant

    Daniel Arnfield committed
Showing with 1 addition and 0 deletions.
  1. +1 −0 activesupport/lib/active_support/dependencies.rb
View
1 activesupport/lib/active_support/dependencies.rb
@@ -640,6 +640,7 @@ def to_constant_name(desc) #:nodoc:
end
def remove_constant(const) #:nodoc:
+ return false unless qualified_const_defined? const
# Normalize ::Foo, ::Object::Foo, Object::Foo, Object::Object::Foo, etc. as Foo.
normalized = const.to_s.sub(/\A::/, '')
normalized.sub!(/\A(Object::)+/, '')
Something went wrong with that request. Please try again.