public
Last active

  • Download Gist
application_controller.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
class ApplicationController < ActionController::Base
protect_from_forgery
 
def current_ability
@current_ability ||= Ability.new(current_member)
end
 
rescue_from CanCan::AccessDenied do |exception|
flash[:alert] = "Access Denied."
redirect_to root_url
end
 
private
 
def current_member
@current_member ||= Member.find(session[:member_id]) if session[:member_id]
end
 
def member_signed_in?
! current_member.nil?
end
 
helper_method :current_member
helper_method :member_signed_in?
 
def authenticate_member!
unless member_signed_in?
session[:ref] = request.url
redirect_to login_url, :alert => "You must first log in to access this page"
end
end
 
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.