Rails 3:控制器内的@template 变量为零 [英] Rails 3: @template variable inside controllers is nil
本文介绍了Rails 3:控制器内的@template 变量为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经开始使用 rails 3 beta3 并且我看到控制器中的 @template 变量为零.如何在控制器内调用辅助方法?谢谢
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 变量为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文