我已经成功安装了描述性统计数据,并尝试使用提供的方法(如Variance等),它会不断抛出未定义的方法“方差”。我认为这些方法只是内置的,可以立即使用。
Scores_controller.rb
def index
statsD = User.all.extend(DescriptiveStatistics)
@var = Score.variance(&:strokes)
end
index.html.erb
Variance: <%= @var %>
我正在尝试将统计信息应用于满分的表格。请帮忙。
您必须为要使用的模型扩展DescriptiveStatistics。看起来您正在扩展User
但想使用Score
def index
scores = Score.all.extend(DescriptiveStatistics)
@variance = scores.variance(&:strokes)
end
现在在您看来
Variance: <%= @variance %>
看看这个示例应用程序https://github.com/mzaragoza/sample_descriptive_statistics
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句