B
barjunk
I found this snippet in code called acts_as_authenticated. I thought
it interesting but hard to understand at first.
@current_user ||= (session[:user] && User.find_by_id(session[:user]))
|| :false
Now for some possible embarrassment.
@current_user should return a value unless it is nil.
If nil(false),
then @current_user is set to session[:user] if session[:user] &&
User.find_by_id return true
otherwise, @current_user becomes false
Am I even close?
Mike B.
it interesting but hard to understand at first.
@current_user ||= (session[:user] && User.find_by_id(session[:user]))
|| :false
Now for some possible embarrassment.
@current_user should return a value unless it is nil.
If nil(false),
then @current_user is set to session[:user] if session[:user] &&
User.find_by_id return true
otherwise, @current_user becomes false
Am I even close?
Mike B.