Elegant way to structure models into subfolders without creating submodules

前端 未结 10 545
一整个雨季
一整个雨季 2020-12-04 08:24

I have numerous models in my app/models folder. I\'d like to clean this folder up a little bit. Move models that belong to each other in subfolders. The problem is that by c

10条回答
  •  独厮守ぢ
    2020-12-04 09:02

    This worked for me in Rails 5.

    Adding the following to application.rb

    config.autoload_paths += Dir[ Rails.root.join('app/models/**/') ]
    

    Beware though that you cannot have the same name on your folder as any of your models.

提交回复
热议问题