问题:如何从不同的控制器和模型中获取控制器中相互关联的数据?
问题:我需要我的@order.seller_id(与@user.id 匹配),然后我需要@user.stripe_token。
所以我最终需要来自正确 user_id 的@user.stripe_token,它通过@order.seller_id 匹配
订单有一个卖家 ID,它是一个用户 ID。此 id 在所有附加了用户的表中都是相同的。因此,为了转移资金,我需要与 Seller_id 关联的正确@user
这是我需要从我 的订单控制器中获得的一段代码:(当订单更新时,费用被捕获并且卖家收到佣金)它可能没有设置 100% 正确 atm 但这是我目前所处的位置。
charge = Stripe::Charge.create({
:amount => (@order.order_price).to_i * 100,
:description => 'Rails Stripe customer',
:currency => 'usd',
:customer => @order.stripe_customer_token,
})
transfer = Stripe::Transfer.create({
application_fee_percent: 75
:currency => 'usd',
destination: ---here's where i need the correct @user.stripe_token ---,
transfer_group: "notes_328324"
})