I’m working on a rails application that will allow customers to sign
up for an account with a particular plan (i.e. Free, Basic, Premium,
etc) that defines what features are available, etc. Pretty standard
stuff you see everywhere, however, not something I’ve implemented
before.
I’m struggling with trying to figure out “the rails way” - if there is
one. Are there best practices you guys typically follow when
implementing something like this. Don’t want to reinvent the wheel
here.
The direction I’ve started down is something like this:
class Account < ActiveRecord::Base
belongs_to :subscription_plan
delegate :limit, :to => :subscription_plan
delegate :feature_allowed, :to => :subscription_plan
end
Table name: subscription_plans
id :integer not null, primary key
plan_name :string(255)
limit :integer
feature_allowed :boolean
class SubscriptionPlan < ActiveRecord::Base
has_many :accounts
end
But I’m not sure if making the SubscriptionPlan an active record class
and defining all the plans in the database is the best way to go, or
whether it makes more sense to create something like
FreeSubscriptionPlan, BasicSubscriptionPlan, PremiumSubscriptionPlan,
etc as just regular classes.
Anybody with thoughts on this or a pointer to some good resources?