Forum: Ruby on Rails Issue with session variables

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E4c4a05719644c37f02dc5181de7c8c5?d=identicon&s=25 Seth Buntin (Guest)
on 2006-04-10 16:06
I had (at one time) got this thing working but it doesnt' seem to work
any more.  I am trying to display a specific user menu depending on the
session variable.  Here is what I have:

<% for @role in @session[:user][:role] %>
	            <% if @role.role_id == '1' %>
	               <li><% link_to "Create Resource", :controller =>
"admin", :action => "new_resource" %></li>
	               <li><% link_to "View New Resources", :controller =>
"admin", :action => "list_new_resources" %></li>
	               <li><% link_to "View All Resources", :controller =>
"admin", :action => "list_resources" %></li>
	               <li><% link_to "Users", :controller => "admin", :action
=> "list_users" %></li>
	            <% elsif @role.role_id == '2' %>
	               <li><% link_to "Create Resource", :controller =>
"admin", :action => "new_resource" %></li>
	               <li><% link_to "View New Resources", :controller =>
"admin", :action => "list_new_resources" %></li>
	               <li><% link_to "View All Resources", :controller =>
"admin", :action => "list_resources" %></li>
	            <% elsif @role.role_id == '3' %>
	               <li><% link_to "Create Resource", :controller =>
"admin", :action => "new_resource" %></li>
	            <% end %>
			<% end %>

When I do @session[:user][:role].inspect I get:

[#"Administrator", "info"=>"Can do anything.", "role_id"=>"1",
"id"=>"1", "user_id"=>"1"}>]

Which is what I suspect.  But my menu is blank and nothing is displayed.

Thanks for the help.

Seth
This topic is locked and can not be replied to.