A user model in all controllers in 6 lines of code


Well it took a bit of research, and making a fool out of myself; but I
found a way to get a user model from the session and have it
accessible in every controller and view in 6 lines of code.

In the ApplicationController write

model :user
before_filter :set_user
def set_user
@user = session[:user] ||= User.find_by_username(‘nobody’)

I have redeemed myself (whoohoo!!)