-
Notifications
You must be signed in to change notification settings - Fork 10
Description
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.