Answer the question
In order to leave comments, you need to log in
The array grows after page reload, why is this happening?
Hi all. For some reason, the array after .push() is not reset when the page is reloaded. I can't understand why.
class Stats
class << self
attr_accessor :condition, :result
end
@result = []
@condition = {}
def self.get_calculate_stats_by_model(model)
tracks = Track.all
# (...)
tracks.each do |track|
@result.push(Bar.get_stats_hash(track)
end
return @result
end
end
class StatsController < ApplicationController
before_action :set_default_params
def campaigns
@stats = Stats.get_calculate_stats_by_model(Campaign)
render 'stats'
end
private
def set_default_params
@condition = {
:date_from => params[:date_from] || Date.today-7,
:date_to => params[:date_to] || Date.today,
}
Stats.condition = @condition
end
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question