I plan on giving different logic to different categories and I don’t know if I should make 20 different models or if I can have just one StoreCategory model and put the logic in there. Some of the logic will be small and others large.
So If I had different store categories like discount, online, delivery, retail, etc, and wanted to give them their own special logic, what should I do?
It’s a good question. In your place, I would create a class “Category” and my other classes inherit from the first. In the Category class I would put the shared code and the specific code in subclasses. You could use polymorphic associations if it’s necessary. It’s just an idea.
Edit 1 : Add code example
the function something_private is called after the save of each subclasses. I think it’s clear and organisated. It works like ApplicationController class.