This project is archived and is in readonly mode.

#5735 ✓stale
Bruno Michel

Weird classes namespace whith cache_classes = false

Reported by Bruno Michel | September 29th, 2010 @ 08:45 PM

Hi,

I've observed a weird behavior of loading classes with namespace. I have a class that is not in a module:

class RedactionControllers < ActionController::Base
end

I can access it normally:

Loading development environment (Rails 3.0.0)
ruby-1.9.2-p0 > RedactionController 
 => RedactionController

But I should not be able to access it in a namespace:

ruby-1.9.2-p0 > Redaction::RedactionController
 => RedactionController

But, if I change config.cache_classes from false to true (in my development environment), I have the expected behavior:

ruby-1.9.2-p0 > Redaction::RedactionController
NameError: uninitialized constant Redaction::RedactionController

This bug has some consequences. In my case, I have this route:

namespace :redaction do
  root :to => "redaction#index"
end

Everything works well in development (with config.cache_classes = false), but it explodes in production (with config.cache_classes = true):

Routing Error
uninitialized constant Redaction::RedactionController

We should fix this difference between development and production to avoid that developers discover some bugs on the production.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages