Topic: static variables works differently in two different envs

example code is as follows,

class Movie
  @@name = []
  def self.name
    @@name
  end
end

class MoviesController < ApplicationController
   def index
     Movie.name.push "x"
     render :text=>"#{Movie.name.length}"
   end
end

Here is the issue : if we run the project in dev environment, every time when i invoke index method in movies_controller it displays same value as 1. Which means static variable gets reset request by request.But this behavior changes when i run it in test env. Then the display gets increased in each requests. eg:-1,2,3…. This means static variable does not get reset for the each request.

Any explanations for this different behaviors ?

Last edited by Shamika (2010-04-21 06:19:12)