Take the 2-minute tour ×

I have a rake task that calls the methods of a model in which i have defined some methods. However, I need to also run the rake task in a different database with the clone table. So I ended up creating a 2nd model that inherits from establish connection for details of the other database. I am considering adding the same methods in model 1 to the 2nd model. But this is not very DRY at all. And I have a ton of operations I am doing in the rake task for the first model that I would like to also run for the 2nd model. How should I handle this design?

share|improve this question
You can use observer in rails also –  JohnnyB Jun 12 '13 at 11:31
add comment

2 Answers

You can use a module:

module M
  def foo

class A
  include M

class B
  include M

A.new.foo # :foo
B.new.foo # :foo
share|improve this answer
add comment

Your Answer


