在更新后继续控制器操作之前,如何等待Rails服务响应



在我的网站上,用户可以通过simple_form_for:上传文档(感谢Cloudinary gem(

<%= f.cl_image_upload(:ids, allowed_formats: %w(jpg jpeg png)) %>

这些文档通过其API发送给Stripe。所以在我的用户模型中,我放了:

after_update send_documents_to_stripe, if: :documents_are_upload?

(它只是检查用户是否上传了他的文档,如果上传了,则调用将文档发送到Stripe的功能(

除了after_update等待文档输入数据库,但不等待文档在Cloudinary上可用。

因此,当我试图将文档发送到Stripe时,我会收到以下错误:

错误表单轨道

有人知道在将文档发送到Stripe之前,我如何从技术上确保Cloudinary已经收到用户的图像?

非常感谢!

不确定Cloudinary的内容,但您也可以完全在客户端完成,直接上传到Stripe:https://jsfiddle.net/thorstripe/bdm3j2rn/

console.log("Code because I linked a JSFiddle...");

您可以尝试使用after_save而不是after_update

最新更新