I’m adding payment plans to an app. The requirements are simple: each
User has resource limits in the app (max. number of photos) and is moved automatically to the correct
Plan as they add or remove photos.
User moves to a different
Plan the change is pushed to the appropriate Stripe customer via the API and they are billed at the end of the month accordingly.
User does not explicitly change their plan themselves, nor can they be on more that one plan at once I don’t see the need for a
Subscription model. I’m keeping it simple with a one-to-one between
In fact the only reason I have a
Plan model at all is to avoid having to call the Stripe API every time I move a
User to a different
The associations I have are:
# user.rb class User < ActiveRecord::Base has_many :photos belongs_to :plan end
# plan.rb class Plan < ActiveRecord::Base has_many :users end
This is a multi-tenanted app and since
User is the tenant somehow it doesn’t feel right for it to
belongs_to another object.
Do you think I’ve over-simplified this? Is there a better way to associate