我不太确定如何描述这个问题,所以将尝试清楚。停止发布到外部服务寻找用户ID
我们的Rails应用程序中有一个页面,我们的客户可以更新其信用卡详细信息。表单发布到外部服务以验证详细信息。然后透明地重新导向给我们。
最初,我在自己的控制器中进行了测试(完美工作),但我刚刚在我的users_controller中移动了它。
表单帖子和重定向到一个确认操作,它会进行一些检查。当我从用户控制器内发帖时,出现以下错误:
Couldn't find User with id=k2hx5p36w3g9rxsz
事实上,这是事务的ID。不是用户。
的URL看起来是这样的:
http://localhost:8080/settings/confirm?http_status=200&id=k2hx5p36w3g9rxsz&kind=update_payment_method&hash=9c85b12c1242cd58de27b2582c934e34a0e9455e6
在我的控制,我有这样的:
def billing
@user = current_user
@credit_card = current_user.default_credit_card
@tr_data = CreditCard::TransparentRedirect.update_credit_card_data(:redirect_url => confirm_credit_card_info_url, :payment_method_token => @credit_card.token)
...
end
def credit_card_confirm
@user = current_user
@result = CreditCard::TransparentRedirect.confirm(request.query_string)
if @result.success?
redirect_to user_billing_path, :notice => "Credit card updated"
else
render :action => "billing"
end
end
在我的路线:
match '/settings/confirm' => 'users#credit_card_confirm', :as => :confirm_credit_card_info
我能做些什么来避免它将ID作为用户ID?
就是这样。使用load_and_authorize_resource和skip_authorize_resource停止验证。干杯。小号 – simonmorley