ApplicationRecord in Rails 5
Many times we do feel need to add a self desired functionality to ActiveRecord::Base and Monkey patching used to serve the purpose. Even though it worked just fine, there was no established structure to it. Often I’ve seen such monkey patches scattered all over the code-base adding to further confusion instead of providing any real value.
Rails 5 solves this by adding an abstract class ApplicationRecord to your app/models:
class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end
Now, you can add your modifications to this class:
class ApplicationRecord < ActiveRecord::Base include CommonWellTestedMethods self.abstract_class = true end
and since all your models will inherit from ApplicationRecord instead of ActiveRecord::Base you would get the desired effect and a commonly-practiced place to store your patches.