私は、顧客向けのバックエンド管理パネルを作成中です。
ユーザーが毎月のサブスクリプションをアップグレードおよびダウングレードできるようにする機能を統合しています。これは、billing_plans テーブルに新しいモデルを追加することを意味します。
アカウントとプランの間の関係を正しく取得しようとして行き詰まっています。
私はbilling_planモデルを持っています:
class BillingPlan < ActiveRecord::Base
self.table_name = "billing_plans"
has_many :accounts, primary_key: 'name', foreign_key: 'audio_billing_model'
end
およびアカウント モデル:
class Account
has_many :contacts
belongs_to :user, primary_key: :email, foreign_key: :billing_email_address
has_one :billing_plan, foreign_key: 'name', primary_key: 'audio_billing_model'
end
私はこれが他の人を助けることができると確信しており、誰かが以前に遭遇したに違いないと確信しています.