Hi there, I am new in Ruby.
I got a question, maybe it’s stupid.
There is controller named ‘home’, and a action named ‘test’ existed.
And I defined a class variable named ‘@@total’
looks like this:
class HomeController < ApplicationController
@@total = 0
@@total += 1
render :text => @@total.to_s
The logic is very clear and simple, I wanna increase the value of
@@total when I call it every time.
So I connect the url: http://localhost:3000/home/test to try it.
But it ALWAYS responses me “1”, there is no accumulation. What’s going
I read the Ruby book and api document, they say the class variable
should act likes a static variable in Java or C++.
But I don’t get the result I espected. Could somebody tell me why?