Skip to content

Instantly share code, notes, and snippets.

@joker1007
Created June 17, 2012 09:03
Show Gist options
  • Save joker1007/2943955 to your computer and use it in GitHub Desktop.
Save joker1007/2943955 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :current_user
protected
def current_user
@current_user ||= User.where(:id => session[:user_id]).first
end
def require_authenticate
unless current_user
redirect_to root_url
return false
end
end
helper_method :current_user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment