Hello everyone, there was a question of splitting the application into logical parts, i.e. at least backend, frontend. How I imagine the structure of the application:

-app -backend -controllers -models -helpers -assets -views -frontend -controllers -models -helpers -assets -views -common -controllers -models -helpers -assets -views 

At the moment I don’t know if it is possible to implement it in the rails, googling hasn’t helped yet, but I think that such a structure would be much better than creating a type separation in one application

 -controllers -frontend/ -backend/ -common/ 

In application.rb, the config root property is there, but this is the root of the entire project, i.e. after reassigning it for example app / backend, the rails start looking for all the files that are in / applications in the app / backend (which is logical in principle).

In general, ideally, I rely on the subdomain to remap the path to the app app, something like this:

 config.path_to_app = case request.subdomain when 'admin' then 'app/backend' when 'api' then 'app/api' else 'app/frontend' end 

Please help me figure out whether it is possible to break the application in this way, or at least advise best practice.

    1 answer 1

    Faced the same problem. Rails Engine came to the rescue. The bottom line is that the built-in application is created, with its own routes, and file structure. Then this application (Engine) is connected to the main project as gems, indicating the path where it is located. And in routes.rb main application, the routes created by the Engine are mounted.

    Read more here: http://rusrails.ru/engines

    • Thank you, read, a great solution, be sure to try. - tsamsiyu