Skip to content

Example in readme throws InvalidHandler exception on startup #26

@thisdotrob

Description

@thisdotrob

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions