I have statements such as @user = User.find(current_user.id) throughout my app.
Sometimes a user might enter with a nil variable (such as a new user for whom current_user is nil).
I'm sure the dumb way to do this would be to scatter if statements everywhere like...
if current_user.exists?
@user = User.find(current_user.id)
else
redirect_to root_url
---*or*---
@user = "new" # for use with if/case statements later on
end
What is the elegant way to deal with this confusion?