Skip to content

Instantly share code, notes, and snippets.

@infernalmaster
Created January 3, 2019 17:29
Show Gist options
  • Save infernalmaster/3429d08e49e06fa7a7201a1b1c7b51b4 to your computer and use it in GitHub Desktop.
Save infernalmaster/3429d08e49e06fa7a7201a1b1c7b51b4 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
include Pundit
protect_from_forgery with: :exception
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def user_not_authorized
flash[:alert] = 'You are not authorized to perform this action.'
redirect_back(fallback_location: root_path)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment