2016-09-29 60 views
0

您好我昨天使用Passenger/Capistrano和Nginx服務器將應用程序部署到VPS。Braintree結帳在部署後給出錯誤`Braintree :: ConfigurationError`

除訂購頁面上輸入checkout按鈕外,其它均順利運行。

然後應用程序崩潰,並在production.log有這個錯誤行Braintree::ConfigurationError (Braintree::Configuration.merchant_id needs to be set): app/controllers/orders_controller.rb:22:in 'new'

的事情是Merchiant_id設置,我完全失去了。

部署之前我將Sandbox API密鑰更改爲Production API密鑰application.yml。我使用​​來隱藏API keys

當我在運行這個localhost之前,部署一切正常。

我已經一遍又一遍地瀏覽Braintree指南。我找不到任何錯誤。

我失去了一些東西在這裏?

這裏是orders_controller.rb是錯誤來自。

class OrdersController < ApplicationController 

include CurrentCart 
before_action :set_cart, only: [:new, :create] 
before_action :set_order, only: [:show, :edit, :destroy] 

def index 
    @orders = Order.all? 
end 

def new 
    @images = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"] 
@random_no = rand(5) 
@random_image = @images[@random_no] 

    if @cart.product_items.empty? 
     redirect_to root_url, notice: 'Your Cart is Empty' 
     return 

    end 
    @order = Order.new 
    @client_token = Braintree::ClientToken.generate #this is line 22 were the error is 
end 

def create 
    @order = Order.new(order_params) 
    if @order.save 
     charge 
     if @result.success? 
      @order.add_product_items_from_cart(@cart) 
     Cart.destroy(session[:cart_id]) 
     session[:cart_id] = nil 
     OrderNotifier.received(@order).deliver 
     redirect_to root_url, notice: 'Thank You for Your Order' 
     else 
      flash[:error] = 'Please Check Your Cart' 
      redirect_to root_url, alert: @result.message 
      @order.destroy 
     end 
    else 
     @client_token = Braintree::ClientToken.generate 
     render :new 
    end 
end 


def show 

end 


def destroy 
    @order.destroy 
    redirect_to root_url, notice: 'Order deleted' 
end 

private 

def set_order 
    @order = Order.find(params[:id]) 
end 

def order_params 
    params.require(:order).permit(:name, :email, :address, :city, :country) 
end 

def charge 
    @result = Braintree::Transaction.sale(
     amount: @cart.total_price_usd, 
     payment_method_nonce: params[:payment_method_nonce]) 
end 

end 

回答

1

我有一次類似的問題,基本上它是相同的錯誤。

我做什麼我的情況來解決,這是在添加config/application.ymlset :linked_files了`deploy.rb``

太行會是這個樣子set :linked_files, %w{ config/application.yml}

然後你再部署在你面前必須在服務器上創建application.yml。最有可能是在~/YOURAPP/shared/config$

你複製/粘貼從application.yml代碼你的機器上的~/YOURAPP/shared/config/application.yml

我幾乎可以肯定,這增加將解決您的問題

+0

好,謝謝,我會檢查出來......希望這能解決它 – DaudiHell

+0

沒有....我得到一個新的錯誤,在服務器上缺少application.yml .....猜猜我必須在服務器上創建它 – DaudiHell

+0

對不起,當然。 ....你必須這樣做...我會更新答案,如果它的工作 – Slowboy