2
嘿家伙!我遇到了一个让我疯狂的问题。查看无法看到在ApplicationController中定义的实例变量,在Rails中
我定义内的实例变量我ApplicationController
:
def initialize
@stylesheets = []
end
当我尝试从视图访问它,说SomeNamespace :: SiteSection(index.html.erb):
<% @stylesheets << "some-stylesheet" %>
<h1>Blablabla</h1>
实例变量@stylesheets
不可见,即红宝石表示它没有被定义。
那么,我如何让这个实例变量在视图中可见?
在此先感谢。
附加信息:
- 我使用Ruby 1.9.2与3.0.4轨道
- 我使用的命名空间(该
ApplicationController
没有命名空间)
非常感谢,男士!它的工作完美无瑕。 – EdMelo 2011-02-22 18:54:30