我有个帮手控制器: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