This project is archived and is in readonly mode.
Model with namespace doesn't work well
-
Andrew White
- State changed from new to duplicate
- Importance changed from to Low
This is a duplicate of #5383 AS dependencies resolver broken: not missing constant error - if you rewrite your class definitions so that they're not inline everything will work, e.g:
module Admin class UsersController < ApplicationController @users = User.all end endThis is because Ruby searches for constants in Object first when defined as ModuleName::ClassName but inside the parent module when nested properly. The first call works because the constant hasn't been loaded yet but the second call finds the already loaded constant. It works fine either way in production because all the models are preloaded. I had a look at seeing if it is fixable but there's no way of intercepting the lookup.