- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 StripeEvent gem处理来自 Stripe 的网络 Hook 。
在我的 Rails 初始化程序中,我得到了这个:
StripeEvent.configure do |events|
events.subscribe 'invoice.payment_succeeded', PaymentSucceeded.new
events.subscribe 'invoice.payment_failed', PaymentFailed.new
end
我还有一个文件夹app/stripe_events
,我在其中保存如下类:
class PaymentFailed
def call(event)
StripeMailer.admin_payment_failed(event.data.object).deliver_now
end
end
问题是我时不时地收到这个错误:
ArgumentError (A copy of PaymentFailed has been removed from the module tree but is still active!)
我猜这是因为 app
中的所有内容都被 Rails 不断地重新加载,而初始化程序中的 StripeEvent.configure
位却没有?
如何预防?
感谢您的指点。
最佳答案
对于那些遇到这个问题的人,events.subscribe
的第二个参数可以是一个 lambda,它可以解决这个问题:
StripeEvent.configure do |config|
config.subscribe 'customer.subscription.created', ->(event) {
RecordStripeSubscription.new.call event
}
end
关于ruby-on-rails - 如何使用 StripeEvents/Webhooks 防止 ArgumentError(PaymentFailed 的副本已从 > 模块树中删除但仍处于事件状态!)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48640498/
我正在使用 StripeEvent gem处理来自 Stripe 的网络 Hook 。 在我的 Rails 初始化程序中,我得到了这个: StripeEvent.configure do |event
我正在使用 StripeEvent gem处理来自 Stripe 的网络 Hook 。 在我的 Rails 初始化程序中,我得到了这个: StripeEvent.configure do |event
我是一名优秀的程序员,十分优秀!