Hello everyone,
Do you feel it? The little shiver down your spine when you think of "namespacing" in rails? To some thats a common feeling, to people like myself who enforce absolute organization have already thought about the need for namespaces in rails.
Now I do understand this is an ongoing effort... to some degree. Controllers and routes, from my experiences work well, that being, under a Namespace::Classname convention.
At this stage, we need to solidify a convention for namespaces with models. It seems the functionality is halfway there and we need some sort of closure on the issue. As it stands, the easy solution which many people has been using is to just prefix the class name with the "namespace". For example,
class SecurityUser < ActiveRecord::Base end
This also means that associations will also reference the naming convention :security_users. The name used to prefix the class is used throughout the application... redundant! However, what happens if the User class is moved to another "package" or if there is a spelling mistake? The entire application will require refactoring when it should only be changed in a few places pertaining to the namespace. This lends itself for a better solution.
I will agree that for most applications, they don't reach the girth where they even need to take advantage of this type of functionality, but Rails is compared against "enterprise" web application platforms where namespaces are a standard. Name conflicts will happen when reusing modules throughout various applications.
It's simple.
app/models/security/ app/models/security/user.rb
class Security::User < ActiveRecord::Base end
by default, the table name should be security_user and the associations can remain :users. There shouldn't need to be a app/ models/security.rb class that references the table "securities".
I am not a rails core developer, so I do not have the roadmap of the architecture in mind. But there should be something taken into consideration. I'd be willing to make the contribution, I'd just like to hear some more thoughts from other developers, thanks.
Regards,
Peter