Rails 3:控制器内部的@template变量为nil [英] Rails 3: @template variable inside controllers is nil
本文介绍了Rails 3:控制器内部的@template变量为nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经开始使用rails 3 beta3,我发现控制器内的@template变量为nil.如何在控制器内调用助手方法?谢谢
i've started using rails 3 beta3 and I have see that the @template variable inside controllers is nil. How I can call helpers methods inside a controller? Thx
推荐答案
使用view_context
方法代替@template
.
这是因为在Rails 3中引入了新的AbstractController
.
This is because in Rails 3 the new AbstractController
was introduced.
您可以在此处阅读更多信息:
You can read more here:
http://apidock.com/rails/AbstractController/Rendering/view_context
这篇关于Rails 3:控制器内部的@template变量为nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文