slackify
slackify copied to clipboard
Example in readme throws InvalidHandler exception on startup
I've added the RepeatHandler
as documented here but (on Rails 7 at least) this gives an exception: repeat_handler is not defined (Slackify::Exceptions::InvalidHandler)
... in 'constantize': uninitialized constant RepeatHandler (NameError)
.
This is because the Slackify.configure
call in config/initializers/slackify.rb
is attempting to register the handlers, but they have not been loaded by Rails' autoloader yet.
After reading these docs, I tried using Rails.application.config.to_prepare
in config/initializers/slackify.rb
:
Rails.application.config.to_prepare do
Slackify.configure do |config|
config.slack_bot_token = ...
config.slack_secret_token = ...
end
end
This stops the exception on startup, but any changes to the handlers are not loaded until you manually reset the server.
I've also tried adding config.autoload_once_paths << "#{root}/app/handlers"
to config/application.rb
and again it fixes the startup error but changes to handlers are not loaded without manually resetting.
Hey :wave: on the newer rails versions you now need to load the directory with the handlers. Regarding the reload after file change, this is a known thing that I never got to address. I'll try to implement something using ActiveSupport::FileUpdateChecker