I have a Rails app in which the user can subscribe to addons, the list is dynamic and contains currently about 10 addons.
The list specifies which is on/off.
Each addon has a rather unique set of properties.
My current solution is that the application has 2 "parent" models and the one new model for each addon:
class AddonPrototype
has_many :addons
end
class Addon
belongs_to :addon_prototype
belongs_to :user
end
class AddonAlpha
belongs_to :addon
end
class AddonBeta
belongs_to :addon
end
etc..
The model
AddonPrototype
has one instance of each addon, with the default name as the only property.The model
Addon
with the propertiesenabled
,custom_name
. When the user is visiting the page with addons, a check is done to see whether the user has anAddon
instance for each existingAddonPrototype
, or else creating one on the fly.For each addon there is a unique model (e.g.
AddonAlpha
,AddonBeta
etc), with the set of properties apt for each particular addon.
This design feels cumbersome, what could be a leaner setup?