Sha256: 743ec0f02aaba26d80185e64a7f3f298df05bd5cc87d905a2f5fdf4dfc548066

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

module Rostra
  class ApplicationController < ActionController::Base

    include Rostra::Config

    helper_method :user_logged_in?, :main_app_login_path, :main_app_signup_path, :rostra_user

    rescue_from CanCan::AccessDenied do |exception|
      after_access_denied
    end

    def rostra_user
      send(Rostra::Config.rostra_user)
    end

    helper_method Rostra::Config.rostra_user

    def main_app_login_path
      send(:main_app).send(Rostra::Config.main_app_login_path)
    end

    def main_app_signup_path
      send(:main_app).send(Rostra::Config.main_app_signup_path)
    end

    # Check if a user is logged in
    #
    def user_signed_in?
      rostra_user
    end

    private

    # Override <tt>cancan</tt>'s default class of <tt>Ability</tt> to user <tt>Rostra::Ability</tt>.
    #
    def current_ability
      @current_ability ||= Rostra::Ability.new(rostra_user)
    end

    # Override this method to if finer control over what happens when <tt>cancan</tt> denies access.
    #
    def after_access_denied
      redirect_to root_url, alert: "You don't have access to view this page"
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rostra-0.0.14 app/controllers/rostra/application_controller.rb
rostra-0.0.13 app/controllers/rostra/application_controller.rb
rostra-0.0.12 app/controllers/rostra/application_controller.rb
rostra-0.0.11 app/controllers/rostra/application_controller.rb
rostra-0.0.10 app/controllers/rostra/application_controller.rb
rostra-0.0.9 app/controllers/rostra/application_controller.rb
rostra-0.0.8 app/controllers/rostra/application_controller.rb