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
` de here…
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`
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)?
Thanks for your time!