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