On Tuesday, 15 April 2014 20:17:29 UTC-5, Xavier Noria wrote: > > I don't think automatic namespacing is the way to go, but out of curiosity > if user.rb has > > class User < AR::Base > end > > and UsersController references User and triggers loading that file, how > would you put User under a namespace? What about the name of the class? > What about the nesting by which the constants in User are resolved? >
Say the Rails app is named Foo and so the module Foo is the one in config/application. Well then when the autoloader sees a request for constant User for the first time, it would look for a files named user.rb with a class in them named User and load them as module Foo; load 'user.rb'; end -- because UsersController was also so namespaced when it was loaded, further references to User will resolve to Foo::User (because that's how the scoping/namespacing search rules work in Ruby anyway). -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.