【发布时间】:2016-06-29 10:46:06
【问题描述】:
您好,我正在尝试让我的 Braintree 帐户在创建交易时显示错误,但它似乎无法正常工作
- flash.each do |key, value|
%div{:class => "alert alert-#{key}"}= value
def update
result = Braintree::Transaction.sale(
:amount => params[:amount_to_add].to_f,
# :order_id => "order id",
:customer_id => customer.customer_cim_id,
:tax_amount => (params[:amount_to_add].to_f / 11).round(2),
:options => {
:submit_for_settlement => true
}
)
if result.success?
logger.info "Added to #{params[:amount_to_add].to_f} to #{customer.first_name} #{customer.last_name} (#{customer.customer_cim_id})"
customer.store_credit.add_credit(params[:amount_to_add].to_f)
redirect_to myaccount_store_credit_path
# , :notice => "Successfully updated store credit."
else
result.errors.each do |error|
puts error.message
customer.errors.add(:base, error.message)
render :show, :notice => error.message
end
end
end
【问题讨论】:
-
我在终端中得到了响应,但我正在尝试解决如何将这些错误呈现回视图
-
这并没有真正回答我的问题,我只是想将 Braintree 给我的错误返回到表示层
-
不确定您是否遵循我真正需要的内容,以及为什么错误没有像应有的那样提供给表示层
标签: ruby-on-rails error-handling haml braintree