I need to have a variable, that will be available in all controllers. For example, I tried something like:
class ApplicationController < ActionController::Base
@test = 'test string'
...
end
and if I tried to show the content of @test in application.html.erb, so I got the empty result.
One possibility is store the string to session, but this way I would like to use only as the latest possibility…
So I would like to ask you – exist in Rails any elegant way, how to do?
You could use a
before_filterto set the variable:With this you can use
@testin application.html.erb.