Ah. So while my solution of using that branch works for this use-case, it’s only really because you’re not using hanami-db
, not working around the underlying issue of referencing classes before the app is booted.
Tim’s fix is more in-depth, explains the core of the issue, and that approach also fixes this issue with Hanami::View as well.
So, if you remove the github source from the Gemfile, then change your config/initializers/load_hanami.rb
file to:
# typed: ignore
require "dry/monads"
require "dry/operation"
require "hanami/action"
require "hanami/view"
module SportsballHanami
class App < Hanami::App
prepare_container do |container|
container.autoloader.ignore("app")
end
end
class Action < Hanami::Action
include Dry::Monads[:result]
end
end
Hanami.boot
module SportsballHanami
class View < Hanami::View
end
class Operation < Dry::Operation
end
end
HanamiPredictor::Slice.boot
p Hanami.app.slices[:hanami_predictor].keys
That works for me. I’d probably throw the Action in the second section too, to keep the base classes together.