1

My application is getting bigger as it needs to manage more sujects:

  • Common objects such as users and parameters
  • Processes classification management
  • A glossary of terms
  • Etc.

Subjects are loosely coupled. For example, business processes descriptions contain highlighted words that link to the glossary.

I may appear to be maniac, but I'd like to organize my application into subfolders, such as:

app/models/processes_classification/business_area.rb

.................................../business_flow.rb

.................................../business_process.rb

But it seems that Rails does not dig that deep into folders hierarchies. Which would be the best practice to structure a growing application, with loosely coupled subjects, where users and parameters are common to all?

I was thinking of:

having several applications with 1 central Devise instance (is it possible?)

or organizing folders hierarchies to match subjects

Thank you for your help!

user1185081
  • 1,898
  • 2
  • 21
  • 46

1 Answers1

1

You can namespace your model by adding a folder in your models folder and putting all your namesapced models in modules.

So app/models/business_area.rb becomes app/models/processes_classification/business_area.rb

and inside the business_area.rb file

class BusinessArea < ApplicationRecord ... end

becomes:

module ProcessesClassification class BusinessArea < ApplicationRecord ... end end

That will autoload the BusinessArea model, just keep in mind that you will have to refer to it as ProcessesClassification::BusinessArea not just BusinessArea

robertoplancarte
  • 1,133
  • 11
  • 19