Ruby 查看can';在Rails中,看不到ApplicationController中定义的实例变量
嘿,伙计们!我遇到了一个让我发疯的问题 我在我的Ruby 查看can';在Rails中,看不到ApplicationController中定义的实例变量,ruby,ruby-on-rails-3,namespaces,instance-variables,Ruby,Ruby On Rails 3,Namespaces,Instance Variables,嘿,伙计们!我遇到了一个让我发疯的问题 我在我的应用程序控制器中定义了一个实例变量: def initialize @stylesheets = [] end 当我试图从视图访问它时,比如说SomeNamespace::SiteSection(index.html.erb): 类应用程序控制器
应用程序控制器中定义了一个实例变量:
def initialize
@stylesheets = []
end
当我试图从视图访问它时,比如说SomeNamespace::SiteSection(index.html.erb):
类应用程序控制器
<% @stylesheets << "some-stylesheet" %>
<h1>Blablabla</h1>
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_var
private
def set_var
@stylesheets = []
end
end