Sha256: fcac99b81267b789e0e08d36cf093cf4788172157366b91ec6943042e5541db1

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

module Rostra
  class ApplicationController < ActionController::Base

    include Rostra::Config

    helper_method :can_participate_in_rostra?, :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 can_participate_in_rostra?
      rostra_user && rostra_user.can_participate_in_rostra?
    end

    private

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

    # Override this method to if finer control over what happens when +cancan+ 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

5 entries across 5 versions & 1 rubygems

Version Path
rostra-0.3.6 app/controllers/rostra/application_controller.rb
rostra-0.3.5 app/controllers/rostra/application_controller.rb
rostra-0.3.4 app/controllers/rostra/application_controller.rb
rostra-0.3.3 app/controllers/rostra/application_controller.rb
rostra-0.3.2 app/controllers/rostra/application_controller.rb