Sha256: 7c69aca78fbb2803b01b9d5eb97219fd8968b8789350be5818648e718a0b1e1c

Contents?: true

Size: 580 Bytes

Versions: 18

Compression:

Stored size: 580 Bytes

Contents

# config/initializers/pundit.rb
# Extends the ApplicationController to add Pundit for authorization.
# Modify this file to change the behavior of a 'not authorized' error.
# Be sure to restart your server when you modify this file.
module PunditHelper
  extend ActiveSupport::Concern

  included do
    include Pundit
    rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
  end

  private

  def user_not_authorized
    flash[:alert] = "Access denied."
    redirect_to (request.referrer || root_path)
  end

end

ApplicationController.send :include, PunditHelper

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rails_apps_pages-0.6.7 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.6.6 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.6.5 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.6.4 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.6.3 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.6.2 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.6.0 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.16 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.15 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.14 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.13 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.12 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.11 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.10 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.9 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.8 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.7 lib/generators/pages/authorized/templates/pundit.rb
rails_apps_pages-0.5.6 lib/generators/pages/authorized/templates/pundit.rb