On 16-04-2014 16:17, Stephen Paul Weber wrote:

On Wednesday, 16 April 2014 14:06:52 UTC-5, Xavier Noria wrote:

    On Wed, Apr 16, 2014 at 9:03 PM, Stephen Paul Weber
    <singp...@singpolyma.net <javascript:>> wrote:

        If we throw out the magical version (which seems a popular
        opinion, and is certainly quite fine with me), does letting
        the autoloader find AppModule::User in app/models/user.rb
        really break that many expectations?  That and having
        ActiveRecord strip the AppModule prefix off classes for the
        purposes of table naming (probably) I think would be exactly
        the same as the "auto namespace" version of the proposal, only
        without anything being automatic.


    As a Ruby programmer, if I see

        class User < AR::Base
        end

    That User has to belong to Object.


Right, this is why I specifically said we're no longer talking about the "auto namespace" version of the proposal, because of this complaint. Which is fine.

    If an application wants AppModule::User then it can define it that
    way and have autoloading working and everything. Just use Ruby.


I'll have to play with this more, but I'm pretty sure if I name my classes AppModule::User then at the very least that will change what I have to name my tables (or I will have to manually set the table name on each model) -- I will also have to put everything in an 'appmodule' folder for the autoloader, I think, and I'm not sure what the autoloader does for the case when I'm inside an `AppModule` context and I say `User` (which ruby will search for as AppModule::User at some point already, so maybe this particular part will just work as-is).


I don't like the idea of adding more conventions to how autoload works in ActiveSupport/Rails like specifying a default namespace, etc. I'd certainly prefer for all my application-specific classes to be namespaced under the application name, but I still don't know how to do that in a practical way.

Ideally, I'd like to fix this in the Ruby level, instead of the framework/libraries one:

https://bugs.ruby-lang.org/issues/9064

The main problem of namespacing everything is that your routes.rb get more verbose and you'd need to wrap all your codes into a module MyApp-end block, adding an indentation level to all controllers and models for instance...

So, I'd love to be able to specify some kind of C++'s namespace (or Java's package) support to my Ruby files, but currently I don't know about any practical way of doing that and I really believe this is a feature request to be handled by the Ruby language rather than by Rails itself...

--
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.

Reply via email to