I know I can make a module that defines a scope and include this module in a model, following, for example, this question's discussion.
But say I have 100 models, all of which have created_at
fields. I want to have a scope reading from created_at
, but I do not want to manually include the module in all the models. I want to define a scope globally for all models.
Seeing how all models inherit from ActiveRecord::Base
, I keep looking for ways to define a scope there, but my efforts with using concerns end up with errors.
ActiveRecord::ActiveRecordError: ActiveRecord::Base doesn't belong in a hierarchy descending from ActiveRecord