出现此错误:
Started POST "/webhook" for 127.0.0.1 at 2014-10-18 11:50:26 +0300
Processing by Stripe::WebhooksController#webhook as XML
Parameters: {"id"=>"evt_14osuo2XLHInsdy70EAY7Iuf", "created"=>1413622222, "livemode"=>false, ...}
Completed 500 Internal Server Error in 963ms
NameError (uninitialized constant Stripe::WebhooksController::Account):
app/controllers/stripe/webhooks_controller.rb:10:in `webhook'
控制器内的
class Stripe::WebhooksController < ApplicationController
protect_from_forgery :except => [:webhook]
def webhook
@event = Stripe::Event.retrieve(params[:id])
@object = @event.data.object
if @object.object == 'customer'
@account = Account.find(@object.id)
else
@account = Account.find(@object.customer)
end
@subscription = @account.subscription
render nothing: true
end
end
帐户是一个类,我想从这个类中获取一个对象,为什么错误说Stripe::WebhooksController::Account
,找不到任何解释为什么这样做。我怎样才能解决这个问题?
谢谢。
P.S。发现了一个类似的one,但没有答案
答案 0 :(得分:1)
通常不要在Stripe
最好做...
class WebhooksController < ApplicationController
如果你坚持使用命名空间,那么你必须明确Account
在命名空间之外并从root访问。
@account = ::Account.find(@object.id)