I have two models in my rails project that share a lot of traits. They
each have the same 4 properties, and now I need to add 2-3 methods to
each one that will be the same. In the spirit of DRY I am looking for
a solution to write these methods only once.
Both of these models already inherit from ActiveRecord . . . and I
didn’t know if it was safe to just “whip up” a super class for them
both and have them inherit the methods from that(competent at rails
and ruby, but grasping for that intermediate level here). I know that
Enumerable is a mixin that is included in arrays and hashes, etc and
that I can create modules. (where should I put them in rails?). Does
anyone have any good information on subclassing in rails vs mixins?
Tutorials, good write ups or books to help me understand further? Even
your own advice would be great.
Thanks ahead of time