Skip to content

Application container not reloading nested dependencies in Rails Console on Rails 6? #32

Open
@cniessigma

Description

@cniessigma

Describe the bug

Forgive me, I am new to the dry-* community, and have been working in the background on converting our current service objects to the dry ecosystem.

A problem I've having is that I'm having issues reloading our container in a rails console. If I put any files I'd like to include in the container at the root level of the auto_register path it reloads just fine, but if I nest it under another folder, it does not reload.

To Reproduce

# in initializers/system.rb
Dry::Rails.container do
  auto_register!('app/operations')
end

# in `app/operations/concepts/demonstrate_bug.rb`
module Concepts
  class DemonstrateBug
    def demonstrate_bug
      puts 'Demonstrated'
    end
  end
end

And in a Rails console (our app is called Phoenix):

[11] pry(main)> Phoenix::Container.resolve('concepts.demonstrate_bug').demonstrate_bug
Demonstrated
=> nil

So far so good, but when I change something and then reload:

# in `app/operations/concepts/demonstrate_bug.rb`
module Concepts
  class DemonstrateBug
    def demonstrate_bug
      puts 'Demonstrates potential pug'
    end
  end
end
[12] pry(main)> Phoenix::Container.resolve('concepts.demonstrate_bug').demonstrate_bug
Demonstrated
=> nil
[13] pry(main)> reload!
Reloading...
=> true
[14] pry(main)> Phoenix::Container.resolve('concepts.demonstrate_bug').demonstrate_bug
Demonstrated
=> nil

Expected behavior

I would expect changing the file and then reloading the Rails console would change the message in the Rails console to Demonstrates potential bug but it doesn't. Again I am new to this ecosystem so I may be missing something

Your environment

  • Affects my production application: NO
  • Ruby version: ruby 2.7.0p0
  • OS: macOS Catalina

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions