Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cniessigma opened this issue Jun 6, 2020 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@cniessigma
Copy link

cniessigma commented Jun 6, 2020

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
@cniessigma cniessigma added the bug Something isn't working label Jun 6, 2020
@solnic solnic added the help wanted Extra attention is needed label Jun 15, 2020
@solnic solnic added this to the 0.2.0 milestone Jun 15, 2020
@solnic solnic modified the milestones: 0.2.0, 0.3.0 Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants