我在生产中运行我的应用程序时只会出现错误(Heroku)。本地运行正常,我已经测试了一些交易,它的工作原理。我使用的是Braintree沙箱帐户
具体来说,我收到以下错误:
2015-05-18T19:07:53.077006+00:00 app[web.1]: Started GET "/transactions/new" for 160.9.0.125 at 2015-05-18 19:07:53 +0000
2015-05-18T19:07:53.093436+00:00 app[web.1]: User Load (1.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
2015-05-18T19:07:53.095900+00:00 app[web.1]: Braintree::ConfigurationError (Braintree::Configuration.merchant_id needs to be set):
2015-05-18T19:07:53.095898+00:00 app[web.1]:
2015-05-18T19:07:53.095902+00:00 app[web.1]: app/controllers/transactions_controller.rb:54:in `generate_new_client_token'
2015-05-18T19:07:53.095903+00:00 app[web.1]: app/controllers/transactions_controller.rb:9:in `new'
2015-05-18T19:07:53.095905+00:00 app[web.1]:
2015-05-18T19:07:53.095906+00:00 app[web.1]:
2015-05-18T19:07:53.089739+00:00 app[web.1]: Processing by TransactionsController#new as HTML
2015-05-18T19:07:53.094330+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms
所以我的问题是如果我可以在生产中使用braintree沙盒帐户,或者我需要在braintree中切换到生产帐户?沙箱是否导致错误?
配置/初始化/ braintree.rb
Braintree::Configuration.environment = :sandbox
Braintree::Configuration.logger = Logger.new('log/braintree.log')
Braintree::Configuration.merchant_id = ENV['BRAINTREE_MERCHANT_ID']
Braintree::Configuration.public_key = ENV['BRAINTREE_PUBLIC_KEY']
Braintree::Configuration.private_key = ENV['BRAINTREE_PRIVATE_KEY']
配置/ application.yml
# Braintree configuration keys
BRAINTREE_MERCHANT_ID: 'XXXXXXXXXXXX'
BRAINTREE_PUBLIC_KEY: 'XXXXXXXXXXXXXX'
BRAINTREE_PRIVATE_KEY: 'XXXXXXXXXXXXXXXXXXX'
答案 0 :(得分:1)
错误在于我使用的Figaro gem使用ENV和application.yml自动执行。我跑了#34; rake figaro:heroku [intense-harbour-8486]"在我的控制台和一切运行正常。我不知道我需要这样做,因为当我推送我的应用程序时所有宝石都安装在heroku服务器中 -