Class: PandaCms::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
ApplicationHelper, ApplicationHelper
Defined in:
app/controllers/panda_cms/application_controller.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#active_link?, #block_link_to, #component, #level_indent, #menu_indent, #nav_class, #nav_highlight_colour_classes, #panda_cms_editor, #panda_cms_form_with, #selected_nav_highlight_colour_classes, #table_indent, #title_tag

Instance Method Details

#add_breadcrumb(name, path = nil) ⇒ Object



21
22
23
# File 'app/controllers/panda_cms/application_controller.rb', line 21

def add_breadcrumb(name, path = nil)
  breadcrumbs << Breadcrumb.new(name, path)
end

#authenticate_admin_user!Object



42
43
44
# File 'app/controllers/panda_cms/application_controller.rb', line 42

def authenticate_admin_user!
  redirect_to root_path, flash: {error: "Please login to view this!"} unless user_signed_in? && current_user.admin?
end

#authenticate_user!Object



38
39
40
# File 'app/controllers/panda_cms/application_controller.rb', line 38

def authenticate_user!
  redirect_to root_path, flash: {error: "Please login to view this!"} unless user_signed_in?
end


17
18
19
# File 'app/controllers/panda_cms/application_controller.rb', line 17

def breadcrumbs
  @breadcrumbs ||= []
end

#current_userObject

Required for paper_trail and seems as good as convention these days



47
48
49
# File 'app/controllers/panda_cms/application_controller.rb', line 47

def current_user
  PandaCms::Current.user
end

#set_current_request_detailsvoid

This method returns an undefined value.

Set the current request details



27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/panda_cms/application_controller.rb', line 27

def set_current_request_details
  PandaCms::Current.request_id = request.uuid
  PandaCms::Current.user_agent = request.user_agent
  PandaCms::Current.ip_address = request.ip
  PandaCms::Current.root = request.base_url
  PandaCms::Current.page = nil
  PandaCms::Current.user ||= User.find_by(id: session[:user_id]) if session[:user_id]

  PandaCms.config.url ||= PandaCms::Current.root
end

#user_signed_in?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/controllers/panda_cms/application_controller.rb', line 51

def user_signed_in?
  !!PandaCms::Current.user
end