I was trying to get a dynamic array for in RUBY which will be changed dynamically. I could not able to push to class variable. Can any one help how can i do that please see the below code.
class SampleController < ApplicationController
@@array = []
@@x = 0
def ajax_data
y = (rand()*100).round()
@@array << [@@x,y]
@@x += 1
end
end
My Question is that the class variable @@array should increase the size of the array whenever we call to the method ajax_data but it always gives the output of one value like this [ [0, y] ] . I want to increase the @@array and @@x values .
How can we do that ?