Class variables in models

I am trying to do the following:

  • initialise a class variable for a model class (@@sub_types = [])
  • store an array of values into this class variable during the initial
    load of a “model” class
  • use this class variable and the populated array within a class
    method in the same model when servicing subsequent HTTP requests to my

My tests show that the class variable is initialised/populated when
the model class is first loaded (triggered by a model method call in
class ApplicationController) BUT does not persist for use when
processing requests.

fyi, I have configured development.rb to cache classes.

Why is the class variable not persisting across requests?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs