Sha256: 53014da32879eaaf3ccc04940b17891c685919d29cd715084175ac73294614d9

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

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

  include Pundit
  protect_from_forgery
  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(tracks_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

4 entries across 4 versions & 1 rubygems

Version Path
wagon_rails-0.4.0 templates/application_controller.rb
wagon_rails-0.3.0 templates/application_controller.rb
wagon_rails-0.2.0 templates/application_controller.rb
wagon_rails-0.1.0 templates/application_controller.rb