Module: MobileView::ControllerAdditions

Extended by:
ActiveSupport::Concern
Includes:
ForcedSwitching::ControllerAdditions
Defined in:
lib/mobile_view/controller_additions.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from ForcedSwitching::ControllerAdditions

#dismiss_mobile_forcing!, #force_mobile!, #force_non_mobile!, #forced_mobile?, #forced_non_mobile?, #mobile_forcing?

Instance Method Details

#mobile?Boolean (protected)

Test if currently MobileView uses mobile version of view templates.

Situations of “use mobile version” is be determined by the following algorithm:

  1. If using forced switching, then test if force switched to mobile version.

  2. Otherwise, automatically test by User-Agent (done by Rack::MobileDetect).

Returns:

  • (Boolean)


52
53
54
55
56
57
58
# File 'lib/mobile_view/controller_additions.rb', line 52

def mobile?
  if mobile_forcing?
    return forced_mobile?
  else
    return request.headers["X_MOBILE_DEVICE"].present?
  end
end