> On Oct 18, 2017, at 3:56 PM, Matt Wire <mattw...@kidstark.com> wrote:
> 
> Hello all!
> 
> Because Rails apps get cluttered up rather quickly, I am proposing a change 
> to this Rails generator method:
> 
> https://github.com/rails/rails/blob/master/activerecord/lib/rails/generators/active_record/model/model_generator.rb
>  (starting at LOC 29)
> 
> def create_module_file
>   return if regular_class_path.empty?
>   template "module.rb", File.join("app/models", "#{class_path.join('/')}.rb") 
> if behavior == :invoke
> end
>   
>   
> 
> TO
> 
> Enter co
> def create_module_file
>   return if regular_class_path.empty?
>   template "module.rb", File.join("app/models", class_path, 
> "#{class_path.join('/')}.rb") if behavior == :invoke
> end
> de here...
> 
> 
> Some more background and argument:
> 
> when you do something like:
> rails g model admin/dashboard
> rails g model user/dashboard user/profile
> 
> You'll get nicely namespaced AR models and tables. The AR models are placed 
> into a sub-directory within the models directory and a module is placed into 
> the root model directory. The module only contains the table_name_prefix. So 
> why not put that module into the sub-directory with the model(s)?

For concreteness, are you suggesting that the first command there generate the 
file at `app/models/admin/admin.rb`? AFAIK that’s not going to work with the 
existing autoloader - it won’t look there by default, and it would expect a 
file located there to define a class or module named `Admin::Admin` if it did.

—Matt Jones

-- 
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 https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to