From: Stephen Bannasch Date: 2006-04-11T08:55:52+09:00 Subject: Re: class variables and inheritance (ActiveRecord problem) Here's a copy of my test case without using the ActiveSuppoprt's cattr_accessor method: class Klass def prefix @@prefix end def prefix=(value) @@prefix=value end def Klass.show(string) puts @@prefix + string end end puts Klass.prefix.object_id class DerivedKlass < Klass def prefix @@prefix end def prefix=(value) @@prefix=value end end puts DerivedKlass.prefix.object_id Klass.prefix = "123" Klass.show("abc") # => "123abc" DerivedKlass.prefix = "789" DerivedKlass.show("abc")# => "789abc" Klass.show("abc") # => "789abc" which produces: 2968188 2968188 123abc 789abc 789abc I'd like to be able to create a class variable that will apply to all objects made from that class and ALSO create a derived class with a different class variable that is used in objects created from the derived class WITHOUT affecting the class variable defined in the original class. It isn't obvious to me how to do this using class variables so either I'm missing something or there is another way to solve this programming problem. I'm going to look into how Ruby creates class variables. -- - Stephen Bannasch Concord Consortium, http://www.concord.org