Ok, I know this is a bit of a frankenstack, but I'm running JRuby on Rails, and I'm relatively new to both. I see some kind of behavior that I cannot understand, and I would like to know that I am doing something wrong or if this is a problem with my stack. The main problem is that it seems that my class attributes are reinitialized, which I would never have expected.
Here is essentially my code
class MyController < ActionController::Base cattr_accessor :an_attr before_filter :init_an_attr def init_an_attr if @@an_attr.nil? @@an_attr = {} end # do some other stuff here end end
The problem is that every time init_an_attr is called, the if condition is true, and I end up reassigning @@ an_attr.
Is this expected behavior? If so, you can explain why, because for me, an appointment should only happen once.
source share