Sha256: bd243713aaf6a68348856d69caee29d561b742064cb300ba4fc53163be8bea30

Contents?: true

Size: 581 Bytes

Versions: 21

Compression:

Stored size: 581 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] = t(:access_denied)
    redirect_to (request.referrer || root_path)
  end

end

ApplicationController.send :include, PunditHelper

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
abstracted-0.4.6 config/initializers/pundit.rb
abstracted-0.4.5 config/initializers/pundit.rb
abstracted-0.4.4 config/initializers/pundit.rb
abstracted-0.4.3 config/initializers/pundit.rb
abstracted-0.4.2 config/initializers/pundit.rb
abstracted-0.4.1 config/initializers/pundit.rb
abstracted-0.3.4 config/initializers/pundit.rb
abstracted-0.3.3 config/initializers/pundit.rb
abstracted-0.3.2 config/initializers/pundit.rb
abstracted-0.3.1 config/initializers/pundit.rb
abstracted-0.3.0 config/initializers/pundit.rb
abstracted-0.2.9 config/initializers/pundit.rb
abstracted-0.2.8 config/initializers/pundit.rb
abstracted-0.2.7 config/initializers/pundit.rb
abstracted-0.2.6 config/initializers/pundit.rb
abstracted-0.2.5 config/initializers/pundit.rb
abstracted-0.2.2 config/initializers/pundit.rb
abstracted-0.1.2 config/initializers/pundit.rb
abstracted-0.1.1 config/initializers/pundit.rb
abstracted-0.0.15 config/initializers/pundit.rb