Sha256: c2661aec18533cf9e33c66a5130cf86b924b106bdf9d29c45c8ae0c7b5c1b6c9

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

module Georgia
  class ApplicationController < ActionController::Base

    include Pundit
    after_action :verify_authorized
    rescue_from Pundit::NotAuthorizedError do
      redirect_to new_user_session_path
    end

    layout :layout_by_resource

    protect_from_forgery with: :exception

    def current_ability
      @current_ability ||= Ability.new(current_user)
    end

    def current_locale
      @current_locale ||= params.fetch(:locale, I18n.locale.to_s)
    end
    helper_method :current_locale

    private

    def layout_by_resource
      devise_controller? ? "georgia/devise" : "georgia/application"
    end

    def user_not_authorized
      flash[:alert] = "You are not authorized to perform this action."
      redirect_to(request.referrer || root_path)
    end

    # Overwriting the sign_out redirect path method
    def after_sign_out_path_for(resource_or_scope)
      new_user_session_path
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.8.0 app/controllers/georgia/application_controller.rb