Rails 3.2.3
I need to pass a class variable to a view. For some reason I’m unable to do this.
class HomeController < ApplicationController
@@user_id = '1343454'
def index
#.......................
end
def about
#.......................
end
end
/view/home/about.html.erb
<% ....
@@user_id is not visible
... %>
What’s the easiest way to do it?
Please do not use
@@.In your
application controlleryou can define:The helper method will make the
current_useravailable in any controller or view in your application.I believe, ‘1343454’ is just an example. Usually we have something like: