Skip to content

Instantly share code, notes, and snippets.

@NakedMoleRatScientist
Created April 3, 2011 21:06
Show Gist options
  • Save NakedMoleRatScientist/900816 to your computer and use it in GitHub Desktop.
Save NakedMoleRatScientist/900816 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def current_user
@current_user ||= User.find_by_id(session[:user_id])
end
def signed_in?
!!current_user
end
helper_method :current_user, :signed_in?
def current_user=(user)
@current_user = user
session[:user_id] = user.id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment