Any suggestions on when and when not to use STI vs. Concerns?
Concerns. Use multiple tables/models, with same columns names for common attributes, and put common functionality into shared concerns.
STI. Use single table with type column. Put common functionality in base class (AR class that maps to table name), and put distinct functionality into child classes.
How awesome is that, you put together 2 of my most disliked features of rails
STIs require a doctor’s attention… and Concerns are well, concerning!
But seriously, to me an AR::Model is just a database layer, nothing more. It is not a bucket for business logic. That should be in a Ruby class or module, or more likely, many.
As far as STI, I prefer polymorphic associations. But I am also a fan of composition over inheritance, a preference I think Thoughtbot shares. STI screams inheritance and you end up with a bunch of useless columns.
So my in my opinion when should you use Concerns or STI? Never and never Do that shit with composition and stop being so infatuated with the database layer. It is an unhealthy obsession that leads to state, bugs, and slow tests.