Skip to content

Instantly share code, notes, and snippets.

@samuelkobe
Last active December 15, 2015 09:59
Show Gist options
  • Save samuelkobe/5242467 to your computer and use it in GitHub Desktop.
Save samuelkobe/5242467 to your computer and use it in GitHub Desktop.
appl
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
def self.requires_authentication(*actions)
before_filter :authenticate, :only => actions
end
private
def current_user
@current_user ||= Admin.find(session[:admin_id]) if session[:admin_id]
end
def authenticate
puts @current_user.inspect
if @current_user.nil?
redirect_to user_new_path, :notice => "Wait a minute! You're not an Admin."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment