Class: PolicyManager::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
Doorman::Controller
Defined in:
app/controllers/policy_manager/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#admin_userObject



40
41
42
# File 'app/controllers/policy_manager/application_controller.rb', line 40

def admin_user
  self.send("current_#{Config.admin_user_resource.name.underscore}")
end

#allow_adminsObject



11
12
13
# File 'app/controllers/policy_manager/application_controller.rb', line 11

def allow_admins
  return redirect_to pending_user_terms_path unless Config.is_admin?(current_user)
end

#current_userObject



36
37
38
# File 'app/controllers/policy_manager/application_controller.rb', line 36

def current_user
  @_current_user ||=  super || (Config.has_different_admin_user_resource? && admin_user)
end

#docObject



15
16
17
18
19
20
21
22
# File 'app/controllers/policy_manager/application_controller.rb', line 15

def doc
  require "redcarpet"
  @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true, fenced_code_blocks: true)
  lines = File.open( PolicyManager::Engine.root.join("README.md")).readlines
  @html = @markdown.render(lines.join(""))
  render "policy_manager/doc"
  #render inline: html, layout: "policy_manager/application"
end

#set_languageObject



32
33
34
# File 'app/controllers/policy_manager/application_controller.rb', line 32

def set_language
  I18n.locale = Config.user_language(current_user)
end

#user_authenticated?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'app/controllers/policy_manager/application_controller.rb', line 24

def user_authenticated?
  if !current_user
    render :file => "policy_manager/401.erb", 
    :layout => "policy_manager/blank", 
    :status => :unauthorized
  end
end