Write a module containing the necessary methods, and include MyModule as needed.
You can certainly do as @derekerdmann suggested, and create an abstract base class for your models:
class MyBaseModel < ActiveRecord::Base abstract_class = true def my_method(*args) #code goes here end end class MyModel < MyBaseModel end
Remember that it assumes that the string abstract_class = true or single inheritance is inherited.
Personally, I prefer the mixin methodology, because if your models ever diverge in common functionality, you can group common functions into separate modules and include as needed.
source share