The case I've run into the gem *is* namespaced, but with a name that clashed with one of my model names. Rails as currently implemented does not control the namespace, but given how the autoloader works I don't see any reason it couldn't. A middleground would be to have the autoloader expect classes to be so namespaced, and make sure the activerecord stuff, etc, expected it as well -- that has the advantage of being less magical, and the disadvantage of being less magical.
On Tuesday, 15 April 2014 17:30:23 UTC-5, Xavier Noria wrote: > > Rails does not control the namespace. > > User is defined when user.rb is evaluated. Autoloading finds user.rb if > the User constant is unknown, and admin/user.rb if Admin::User is unknown, > but namespace usage is up to the application. > > In my view, namespacing is something code meant to be shared should do, > like a gem. Code not mean to be shared does not need it generally speaking > in my opinion. > > In the rare event of a constant clash because a gem does not use a > namespace then you can workaround that particular situation, but I > personally wouldn't recommend apps to be namespaced as a standard practice. > > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
