Okay to explicitly configure Rails.root?

Hi folks,

I have a multi-tenant application in which most of the contents of each instance’s Rails.root is symlinked to a shared source checkout. Specific per-instance exceptions are config/database.yml and tmp. E.g.

  /var/www/source
    app/
    config.ru
    config/
    ...
  /var/www/cust1
    app -> ../source/app
    config.ru -> ../source/config.ru
    config/
      application.rb -> ../../source/config/application.rb
      boot.rb -> ../../source/config/boot.rb
      cable.yml -> ../../source/config/cable.yml
      database.yml
      ...
    ... 
    tmp/
      cache/
      pids/
      sockets/
  /var/www/cust2
    app -> ../source/app
    ...

This worked fine for Rails 3. But in Rails 7, the code that determines Rails.root uses the call stack and dereferences symlinks. So in the example above, for both cust1 and cust2, bin/rails runner "puts Rails.root" prints /var/www/source instead of /var/www/cust1. Thus, all instances share the same config/database.yml and tmp.

I am aware that I can use environment variables to facilitate a shared config/database.yml, but that’s a significant ops change and I would still be stuck with a shared tmp.

I can override the Rails 7 behaviour by explicitly setting config.root in config/application.rb. E.g.

module App
  class Application < Rails::Application
    config.root = my_own_find_root

    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 7.1
    ...
  end
end

However, I can’t find documentation supporting this approach and would like to hear comments or concerns before I commit.

Thanks in advance.