【发布时间】:2018-10-01 21:47:58
【问题描述】:
我正在使用 Stripe 为我的应用创建支付服务。我有:
#app/services/service_error.rb
class PaymentGateway::ServiceError < StandardError
attr_reader :exception_message
def initialize(message, exception_message: )
# Call the parent's constructor to set the message
super(message)
# Store the exception_message in an instance variable
@exception_message = exception_message
end
end
class PaymentGateway::CreateSubscriptionServiceError < PaymentGateway::ServiceError
end
在我的控制器中我试图运行它:
#app/controller/subscriptions_controller.rb
class SubscriptionsController < ApplicationController
rescue_from PaymentGateway::CreateSubscriptionServiceError do |e|
redirect_to root_path, alert: e.message
end
当我运行我的代码时,我得到了这个错误:
ActionController::RoutingError (uninitialized constant PaymentGateway::CreateSubscriptionServiceError):
我在这里做错了什么?
【问题讨论】:
-
你的 Rails 版本是什么?
-
它的 Rails 5.1.4
标签: ruby-on-rails stripe-payments