gpt4 book ai didi

javascript - 错误: "undefined local variable or method ' e'"inside RegistrationsController

转载 作者:行者123 更新时间:2023-11-28 00:05:08 27 4
gpt4 key购买 nike

我在使用 Stripe Checkout 将电子邮件从 JS 传递到 Rails 时遇到问题。我通过堆栈跟踪在第 21 行和第 25 行不断收到错误未定义的局部变量或方法 'e'。任何帮助将不胜感激。

这是我的代码:

Rails 代码:

def create
**line 21:** @registration = Registration.new registration_params.merge(email: stripe_params[:stripeEmail],
card_token: stripe_params[:stripeToken]) //ERROR
raise "Please, check registration errors" unless @registration.valid?
@registration.process_payment
@registration.save
redirect_to @registration, notice: 'Registration was successfully created.'
rescue
**line 25:** flash[:error] = e.message // ERROR
render :new
end

JS代码:

<script src='https://checkout.stripe.com/checkout.js'></script>
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_xxxxxx',
token: function(token) {
// Use the token to create the charge with a server-side script.
// You can access the token ID with `token.id`
}
});

jQuery('#customButton').on('click', function(e) {
// Open Checkout with further options
handler.open({
name: 'The Climb',
description: 'Individual',
email: 'asdfasdf999@asdf.com',
amount: 3500
});
e.preventDefault();
});

// Close Checkout on page navigation
$(window).on('popstate', function() {
handler.close();
});
</script>

最佳答案

第 24 行应该是:

rescue => e

关于javascript - 错误: "undefined local variable or method ' e'"inside RegistrationsController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31419361/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com