Reputation: 3152
Hey guys! I'm getting a problem that is driving me crazy.
I defined an instance variable inside my ApplicationController
:
def initialize
@stylesheets = []
end
When I try to access it from a view, say SomeNamespace::SiteSection (index.html.erb):
<% @stylesheets << "some-stylesheet" %>
<h1>Blablabla</h1>
the instance variable @stylesheets
isn't visible, i.e., ruby says it wasn't defined.
So, how I make this instance variable visible inside the views?
Thanks in advance.
Additional info:
ApplicationController
isn't namespaced)Upvotes: 2
Views: 3348
Reputation: 83680
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_var
private
def set_var
@stylesheets = []
end
end
Upvotes: 10