gpt4 book ai didi

ruby-on-rails - Stripe API key 缺少 Rails

转载 作者:数据小太阳 更新时间:2023-10-29 08:07:31 26 4
gpt4 key购买 nike

我们正面临 Stripe API key 的问题。到目前为止我所做的是:

  • 设置环境/*.rb 以使用常量使用适当的 Stripe key
  • 使用 Stripe.api_key = STRIPE_SECRET 行创建了一个 config/initializers/stripe.rb
  • 使用 Rails 控制台,STRIPE_PUBLICSTRIPE_SECRET 常量都已设置且可见。 STRIPE_PUBLIC => "pk_test_xxxxxxxxx"

但是,一旦这些都准备就绪,使用浏览器调用 Stripe 的 API 会导致:

Stripe::AuthenticationError in some_controller#some_action

No API key provided. Set your API key using "Stripe.api_key = <API-KEY>". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.

使用网络控制台 gem,我们可以知道网站中的 STRIPE_SECRETSTRIPE_PUBLIC 为 nil。但每次我们运行 rails console 时,我们都会从常量中获取 key 。

最佳答案

我解决了我的问题。在设置环境变量之前,运行rails server的终端已经打开。

因此,运行 source ~/.bashrc(对我而言)或使用新终端对我来说很有效。

真诚地感谢所有试图提供帮助的人!

关于ruby-on-rails - Stripe API key 缺少 Rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34886656/

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