Skip to content

Instantly share code, notes, and snippets.

@wookiehangover
Created February 23, 2012 01:12
Show Gist options
  • Save wookiehangover/1888946 to your computer and use it in GitHub Desktop.
Save wookiehangover/1888946 to your computer and use it in GitHub Desktop.
before_filter :find_user, :only => [:show, :edit, :update, :destroy]
def find_user
id = params[:id] == 'current' ? current_user.id : params[:id]
@user = User.find(id)
end
// and in your application controller
def current_user
if cookies[:auth_token] && !cookies[:auth_token].blank?
@current_user ||= User.find_by_auth_token!(cookies[:auth_token])
else
@current_user = nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment