Skip to content

Instantly share code, notes, and snippets.

@localhots
Created March 6, 2014 16:15
Show Gist options
  • Save localhots/9393197 to your computer and use it in GitHub Desktop.
Save localhots/9393197 to your computer and use it in GitHub Desktop.
Clear impersonation logic in Rails
def session_user
@session_user ||= if current_user.admin? && params[:user_id].present?
User.find(params[:user_id])
else
current_user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment