Displaying 2 results from an estimated 2 matches for "rbac_user_id".
2006 Oct 09
5
Problem setting variables in ApplicationController.
...up on the applicatin.rhtml file. The current_user is
defined in the application controller. But, attempting to assign it a
value while in the application controller results in an ''undefined
method'' error.
ApplicationController ....
def current_user
@cu = ::User.find(session[:rbac_user_id]) || "not logged in"
end
---
++Application.rhtml ++
Admin menu
<% if current_user.has_role?("Admin") %>
menu one
menu two
<%end%>
Apparently the current_user is not created by the time the
application.rhtml is rendered.
I think it might have something to do with...
2006 Jun 02
6
Set instance variable for all actions in the Controller
Can I set an application wide instance variable that is available for all
actions...and their views?
eg.
class ApplicationController < ActionController::Base
@current_user = User.find(session[:user_id])
end
and everywhere I can call @current_user.id and I can get that object? Even
down in the views?
I could not get this to work...
Thanks in advance,
Jeff
-------------- next part