次のようなデータモデルがあります。
Acustomerにはパラメータとして と がsubscription_idありsetup_idます。場合によってcustomerは、パラメータの 1 つだけを持ちます。それ以外の場合は、両方があります。
現在、サブスクリプション フローまたはセットアップ フローのいずれかを介して新しい顧客をSubscription.last作成すると、Setup.last作成された最新の顧客が反映されるか、反映されます (customer_id最後に作成された顧客と等しくなります)。
しかし、私はすべての場合に問題があるCustomer.setup_idかCustumer.subscription_id、ゼロであるという問題を抱えています。
subscription.rbとの両方からの私のコードは次のsetup.rbとおりです。
class Subscription < ActiveRecord::Base
attr_accessible :status, :customer_id
belongs_to :customer
end
class Setup < ActiveRecord::Base
attr_accessible :status, :customer_id
belongs_to :customer
end
そしてでcustomer.rb:
class Customer < ActiveRecord::Base
attr_accessible :email, :name, :stripe_token, :subscription_id, :setup_id, :phone, :plan
has_one :subscription
has_one :setup
end
ここで何が間違っているのかわかりませんが、3 つのデータ モデルが互いに正しく通信できれば幸いです。
編集: ではなくと の両方setupにsubscription属するのは悪いことですか?:user:customer
編集 2 : 現在のデータ モデルを正しく反映するように、setup.rb と subscriptions.rb のコードを更新しました。そしてcustomer.rb、まだ正しいsetup_idまたはを認識していませんsubscription_id