dblock
2011-May-25 17:26 UTC
warning: toplevel constant SomeController referenced by Admin::SomeController
This issue has been discussed before (http://www.ruby-forum.com/topic/ 125392) and after spending a while debugging through this, I still don''t have a solution. Lets try again? I have two controllers, SomeController and Admin::SomeController. When SomeController is loaded first (which happens under spork, found out by editing ActiveSupport::AbstractController) I get warning: toplevel constant SomeController referenced by Admin::SomeController and the second controller is not loaded. The first controller is polluting something for the namespaced controller. I have a rather large project where this happens, so I can''t post it. But I have a 100% repro, so I''d be happy to do some debugging. Help? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Andrew White
2011-May-25 21:38 UTC
Re: warning: toplevel constant SomeController referenced by Admin::SomeController
On 25 May 2011, at 18:26, dblock wrote:> I have two controllers, SomeController and Admin::SomeController. When > SomeController is loaded first (which happens under spork, found out > by editing ActiveSupport::AbstractController) I get warning: toplevel > constant SomeController referenced by Admin::SomeController and the > second controller is not loaded. The first controller is polluting > something for the namespaced controller.Is Admin a class or a module? If it''s a class it''s due to the fact that const_missing searches for constants in ancestors which includes Object when Admin is a class. Since SomeController is defined already in Object it will return that constant along with the warning message. If Admin is a module then the ancestor list is just itself. A couple of ways to workaround the problem, either make Admin a module if possible or nest the public-facing controllers under a different namespace, e.g. Admin::SomeController and Front::SomeController. Andrew -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.