Skip to content

Instantly share code, notes, and snippets.

@kkestell
Created November 10, 2011 14:29
Show Gist options
  • Save kkestell/1354962 to your computer and use it in GitHub Desktop.
Save kkestell/1354962 to your computer and use it in GitHub Desktop.
Login Redirection - ApplicationController
class ApplicationController < ActionController::Base
protect_from_forgery
check_authorization :unless => :devise_controller?
unless Rails.application.config.consider_all_requests_local
rescue_from CanCan::AccessDenied, :with => :render_forbidden
end
private
def render_forbidden(exception)
if user_signed_in?
render :template => "/error/403.html.erb", :status => 403
else
session[:post_auth_path] = request.env['PATH_INFO']
redirect_to new_user_session_path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment