Sha256: cea1acc27696e8ca28afcf7710045adbe9332326e411ace09c9058c7e05ea61e

Contents?: true

Size: 795 Bytes

Versions: 3

Compression:

Stored size: 795 Bytes

Contents

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  before_filter :authenticate_user!, unless: :pages_controller?

  include Pundit
  after_action :verify_authorized, except: :index, unless: :devise_or_pages_controller?
  after_action :verify_policy_scoped, only: :index, unless: :devise_or_pages_controller?

  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized

  private

  def user_not_authorized
    flash[:error] = I18n.t('controllers.application.user_not_authorized', default: "You can't access this page.")
    redirect_to(root_path)
  end

  def devise_or_pages_controller?
    devise_controller? || pages_controller?
  end

  def pages_controller?
    controller_name == "pages"  # Brought by the `high_voltage` gem
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wagon_rails-0.4.3 templates/application_controller.rb
wagon_rails-0.4.2 templates/application_controller.rb
wagon_rails-0.4.1 templates/application_controller.rb