在Rails通知中,我訂閱了「process_action.action_controller」,並且想要向有效負載添加更多屬性。我怎樣才能做到這一點?如何將屬性添加到現有的通知負載?
我已經嘗試使用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