Open stairsj opened 4 years ago
Hi, this happens because the register happens too early in the application initialization cycle. To fix this the register_handler
should be in a to_prepare
callback:
https://guides.rubyonrails.org/configuring.html#initialization-events
The README.md
isn't clear enough on this though, it should be improved.
Hello,
Newbie Ruby developer, I am trying to add a custom github webhook listener to shipit. I have modified by environments/development.rb and added the following lines
Shipit::Webhooks.register_handler('issue_comment') do |params| puts "Webhook Calling issue_comment" end
I end up with the following error message on start
rake aborted! NameError: uninitialized constant Handlers /usr/local/bundle/gems/shipit-engine-0.31.0/app/models/shipit/webhooks.rb:6:in
default_handlers' /usr/local/bundle/gems/shipit-engine-0.31.0/app/models/shipit/webhooks.rb:18:inreset_handlers!' /usr/local/bundle/gems/shipit-engine-0.31.0/app/models/shipit/webhooks.rb:14:in
handlers' /usr/local/bundle/gems/shipit-engine-0.31.0/app/models/shipit/webhooks.rb:22:inregister_handler' /var/shipit/config/environments/development.rb:65:in
block in <top (required)>' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/railtie.rb:216:ininstance_eval' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/railtie.rb:216:in
configure' /var/shipit/config/environments/development.rb:1:in<top (required)>' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:612:in
block (2 levels) ineach' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:611:in
block ininstance_exec' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in
run' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:61:inblock in run_initializers' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:50:in
each' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:50:intsort_each_child' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:60:in
run_initializers' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:363:ininitialize!' /var/shipit/config/environment.rb:5:in
<top (required)>' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:339:inrequire_environment!' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:515:in
block in run_tasks_blocks' Tasks: TOP => railties:install:migrations => db:load_config => environment (See full trace by running task with --trace) ` Any assistance would be greatly appreciated.