Class: AdSpace::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/ad_space/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#_current_userObject



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

def _current_user
  @user ||= User.find_by(id: session[:user_id])
end

#add_breadcrumb(name, path = nil) ⇒ Object



27
28
29
# File 'app/controllers/ad_space/application_controller.rb', line 27

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


23
24
25
# File 'app/controllers/ad_space/application_controller.rb', line 23

def breadcrumbs
  @breadcrumbs ||= []
end

#init_appObject



8
9
10
11
12
13
14
15
# File 'app/controllers/ad_space/application_controller.rb', line 8

def init_app
  AdSpace::App.init request: request

  # 检查权限
  if !_current_user&.admin?
    redirect_to main_app.root_path, alert: "Permission denied - You are not authorized to access this resource.", status: :see_other
  end
end