dry-rb / dry-rails

The official dry-rb railtie

Home Page:https://dry-rb.org/gems/dry-rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to change config.root

ndan opened this issue · comments

This dry-rb/dry-system-rails#16 had broken an ability to set config.root under rails initializer

# config/initializers/system.rb
Dry::System::Rails.container do
  config.root = ::Rails.root.join('app')
end

Then run in rails console

> MyApp::Container.config.root
=> #<Pathname:/path/to/my_app>

# should be
=> #<Pathname:/path/to/my_app/app>

The reason is default_options are merged after container.class_eval(&@container_block) evaluated.
https://github.com/dry-rb/dry-system-rails/blob/master/lib/dry/system/rails.rb#L43

@ndan good catch! I marked this as help wanted for now, I'll try to fix it assuming nobody picks this up but can't tell when exactly.

@ndan I moved it to dry-rails as this project is replacing dry-system-rails

This has been fixed although I don't think it's a good idea to change the root path, unless you want to completely separate from Rails directory structure.