From: MohsinHijazee Date: 2008-02-21T20:24:58+09:00 Subject: Re: Reusing the existing code. On Feb 21, 4:10 pm, prizr...@yahoo.com wrote: > On 21 æÅ×, 13:02, MohsinHijazee wrote: > > > Hi! > > š šI have a new class which needs to reuse the code in two classes. > > But I can only derive it from one class. How should I go about it then? > > Use mixins, by defining modules > > Module A > def afunc; 5; end > end > > Module B > def bfunc; 6; end > end > > class AB > include A > include B > end > > x AB.new > x.afunc # -> 5 > x.bfunc # -> 6 The problem is that the second class which I want to use is derived from the ActionController::Base. I cannot make that class into a module otherwise I would be disturbing a the functionality of the Rails Application.