Class: ApplicationController

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

Overview

Base controller, all other controllers inherit. Pundit controller for application policy

Instance Method Summary collapse

Instance Method Details

#check_for_mobileObject


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

def check_for_mobile
  session[:mobile_override] = params[:mobile] if params[:mobile]
end

#mobile_device?Boolean

Returns:

  • (Boolean)

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

def mobile_device?
  if session[:mobile_override]
    session[:mobile_override] == '1'
  else
    # Season this regexp to taste. I prefer to treat iPad as non-mobile.
    (request.user_agent =~ /(Mobile|webOS)/)
  end
end