Forked from NakedMoleRatScientist/application_controller.rb
Created
April 3, 2011 21:07
-
-
Save rainhead/900818 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
protected | |
def current_user | |
@current_user ||= User.find_by_id(session[:user_id]) if signed_in? | |
end | |
def signed_in? | |
!! session[:user_id] | |
end | |
helper_method :current_user, :signed_in? | |
def current_user=(user) | |
@current_user = user | |
session[:user_id] = user.id | |
end | |
def logout! | |
@current_user = nil | |
session.delete :user_id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment