在Rails通知中,我订阅了"process_action.action_controller",并想要添加更多属性到有效载荷中。我该如何做?
我尝试使用append_info_to_payload,但似乎没有效果。
订阅和以上代码位于Rails引擎中,因此在这里我进行调用以添加它:
我尝试使用append_info_to_payload,但似乎没有效果。
module AppendExceptionPayload
module ControllerRuntime
extend ActiveSupport::Concern
protected
def append_info_to_payload(payload)
super
payload[:happy] = "HAPPY"
end
end
end
订阅和以上代码位于Rails引擎中,因此在这里我进行调用以添加它:
require 'append_exception_payload'
module Instrument
class Engine < ::Rails::Engine
ActiveSupport.on_load :action_controller do
include AppendExceptionPayload::ControllerRuntime
end
end
end
prepend
而不是include
。 - Akinori MUSHA