What are the associations between the models in a subscription/recurring billing Rails app? -


this how schema 4 models look: http://pastie.org/1576759

the plan table stores data on actual plans. subscription stores each month user 're-subscribes' service. transaction stores payment related info.

how associations work between models ?

e.g. user :belongs_to plan, :through => :subscription ?

a subscription "has_many" :plans ?

i bit fuzzy on how ties respect rails , associations.

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 user has 1 subscription @ 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 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -