class variable not retaining its old val after server start

I want to get the names of the subclasses.

In my model class, I have cattr_accessor :subtypes

def self.inherited(sub)    super    @@subtypes ||=    @@subtypes.push(sub.name)    session[:subtypes] = @@subtypes end

@subtypes has names of the subclasses in array, but give nil value
when accessed outside this method since the variable is initialized (in development mode), everytime the classes are reloaded.

So I tried putting it in session, but am getting an exception as "....undefined local variable or method `session' for Sample:Class (NameError)" in my Server startup.

The session doesn't exist in a model. The other problem you will may have is that if your class A has
subclasses B,C,D but for some reason only B & C have been used at some
point then your @@subtypes method will only return [B,C] since D won't
have been loaded.

Fred