Class: ApplicationController

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

Constant Summary

Constants included from ApplicationHelper

ApplicationHelper::CONFIG

Instance Method Summary collapse

Methods included from ApplicationHelper

#active_sidenav_item, #canonical_base, #canonical_base_from_config, #canonical_path, #canonical_url, #dashboard_cookie, #search_enabled?, #set_utm_cookie, #theme

Instance Method Details

#authenticate_admin!Object



31
32
33
34
35
# File 'lib/nexmo_developer/app/controllers/application_controller.rb', line 31

def authenticate_admin!
  return redirect_to new_user_session_path unless user_signed_in?

  redirect_to root_path unless current_user.admin?
end

#not_found(exception = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/nexmo_developer/app/controllers/application_controller.rb', line 20

def not_found(exception = nil)
  redirect = Redirector.find(request)
  if redirect
    redirect_to redirect
  else
    NotFoundNotifier.notify(request, exception)
    not_found_search_results if search_enabled?
    render_not_found
  end
end

#redirect_vonage_domainObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/nexmo_developer/app/controllers/application_controller.rb', line 37

def redirect_vonage_domain
  case request.host
  when 'developer.nexmo.com'
    redirect_to("https://developer.vonage.com#{request.fullpath}", status: :moved_permanently) and return
  when 'developer.nexmocn.com'
    if request.fullpath.include?('?')
      redirect_to("https://developer.vonage.com#{request.fullpath}&locale=cn", status: :moved_permanently) and return
    end

    redirect_to("https://developer.vonage.com#{request.fullpath}?locale=cn", status: :moved_permanently) and return
  end
end