I need to be able to schedule reminders for users. So I thought I could just create a base model Reminder and use STI to make descendant classes which override the function fire(), called when reminder fires. But different user roles have similar types of reminders. So they need to be namespaced, e.g. Adult::BrushTeethReminder sends an email to user, Kid::BrushTeethReminder posts on kid’s FB wall.
Is it possible with STI and how if yes?
Other way I see is to just prefix model names like KidBrushTeethReminder. Or go even deeper – write a factory method which creates objects according to type. Or is there a cleaner way?
I found that you do can use STI for models in different namespaces. You just need to place them in appropriate subfolders. For example,
Kid::BrushTeethRemindershould be placed underapp/models/kidin filebrush_teeth_reminder.rb