JP, It depends on what authorization mechanism you are using, but if the complete user info is stored in the session it would be something like... session[:user].id or, if you are just storing the id in the session and doing a lookup for each access to user data... session[:user] substitute your session variable for the "user" entry. Hope that helps. Nathan
on 2006-05-12 00:44
on 2006-05-12 02:11
on 2006-05-12 02:30
on 2006-05-12 05:17
You should be careful about storing the user object in the session. It's associations will be cached from the first time they are accessed. Either just store the id and query the user each request, or be very sure to reload the stored object and associations when necessary. I prefer the approach of storing the user id in the session and querying it each request. class User < ActiveRecord::Base cattr_accessor :current end Then populate User.current with each request: class ApplicationController < ActionController::Base before_filter do User.current = User.find(session[:user_id]) end end Then you can use User.current anywhere to get the currently logged in user. -Jonathan.