aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-18 20:33 UTC
Can''t have WelcomeController and User::WelcomeController ? namespace anyone !
I have a top level controller and a nested controller with the same name WelcomeController. It works fine in development mode. Then in production mode, it says there are no actions for that controller, and plops out this error... /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ inflector.rb:250: warning: toplevel constant WelcomeController referenced by User::WelcomeController Is''nt that the whole point of modules, there basically a namespace to keep this from being a problem ??? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yasuke
2007-Jun-04 14:41 UTC
Re: Can''t have WelcomeController and User::WelcomeController
I faced the exactly same problem. This is caused by ruby''s language specification, rather than by the implementation of ActiveSupport. When you accessed User::WelcomeController, it is expected that missing of User::WelcomeController raises and Name Error exception. ActiveSupport handles this exception. However, if ::WelcomeController was already loaded, Ruby would treat it as User::WelcomeController, and raise no exception, and ActiveSupport couldn''t work. For example, following code refers Foo::Bar which doesn''t exsist, but this code don''t results in NameError exceptions. ------------ class Foo end class Bar end Foo::Bar ------------ To solve this problem, I added codes like followings: ------------ class User Dependencies.load_missing_constant self, :WelcomeController ... ------------ This results in User::WelcomeController to be always loaded when User is loaded(User will be loaded when you try to access User::WelcomeController). If Ruby supports options or flags to resolve name scopes strictly, it will work well for this problem. But I''m not sure whether Ruby does. aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I have a top level controller and a nested controller with the same > name WelcomeController. > > It works fine in development mode. > > Then in production mode, it says there are no actions for that > controller, and plops out this error... > > /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ > inflector.rb:250: warning: toplevel constant WelcomeController > referenced by User::WelcomeController > > Is''nt that the whole point of modules, there basically a namespace to > keep this from being a problem ???-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---