0
我正在验证应用程序控制器中是否存在“test_results”。它作为局部变量返回。我想打电话给它,并在整个会议期间提供。我怎么做?想要返回一个全局变量而不是本地变量
“test_results” 在应用控制器:
def test_results
(0 .. 4).each do |x| # looks for answers to the first 4 questions
if @answers[x].nil? || @answers[x] == 0.0
return false
break
end
end
return true
end
其它控制器:
before_filter :test_results
if test_results
...do stuff
else
...display "take the test"
end
错误消息从视图:
undefined local variable or method `test_results'
无法找到。 – Jay 2011-06-10 14:19:34
编辑了更多的信息 – LoSciamano 2011-06-10 15:19:56