订阅/定期计费Rails应用程序中的模型之间有什么关联?

这就是四种模型的模式:http://pastie.org/1576759 计划表存储有关实际计划的所有数据。订阅每个月存储用户“重新订阅”该服务。交易存储与支付相关的信息。 模型之间的协会如何运作? 例如。用户:belongs_to计划,:通过=>:订阅? 订阅“has_many”:计划? 关于Rails和关联如何将这一切联系起来,我有点模糊。     
已邀请:
class Subscription < ActiveRecord::Base
  belongs_to :user
  belongs_to :plan
end

class User < ActiveRecord::Base
  belongs_to :plan
  has_many :subscriptions (or has_one, if a user only has 1 subscription at a time)
  has_many :transactions
end

class Transaction < ActiveRecord::Base
  belongs_to :user
  belongs_to :plan
end

class Plan < ActiveRecord::Base
  has_many :subscriptions
  has_many :users
end
    

要回复问题请先登录注册