我有個幫手控制器:Ruby on Rails的助手 - 在助手使用實例變量
module CourseStepsHelper
def current_quiz_result
@course_step.step.step_quiz.quiz_attempts.where(:patient_id => current_user.id, :step_quiz_id => @course_step.step.step_quiz.id).first
end
end
它可以訪問其在CourseSteps控制器秀「行動」定義@course_step。這是在助手中使用實例變量的常見做法嗎?
請嘗試更清楚地說明你的問題。 – polarblau 2011-03-11 15:57:06
@polarblau我已經清理了我的問題 – 2011-03-11 16:38:43
實際的答案請參閱http://stackoverflow.com/questions/6474596/should-rails-helpers-assume-an-instance-variable-exists-or-should-they-receive -t – jibiel 2012-06-27 07:12:04