lib/mobylette/respond_to_mobile_requests.rb
# This method enables the controller do handle mobile requests
#
# You must add this to every controller you want to respond differently to mobile devices,
# or make it application wide calling it from the ApplicationController
#
# Possible options:
# * fall_back: :html
#     You may pass a fall_back option to the method, it will force the render
#     to look for that other format, in case there is not a .mobile file for the view.
#     By default, it will fall back to the html format.
#     If you don't want fall back at all, pass fall_back: false
# * skip_xhr_requests: true/false
#     By default this is set to true. When a xhr request enters in, it will skip the
#     mobile verification. This will let your ajax calls to work as intended.
#     You may disable this (actually you will have to) if you are using JQuery Mobile, or
#     other js framework that uses ajax. To disable, set skip_xhr_requests: false
# * mobile_user_agents: proc { /user_agents_match/ }
#     If you want to restrict the user agents that will be considered mobile devices,
#     you can send a custom proc/object that returns the matching regex you wish.
# * devices: {device_name: /device_reg/, device2_name: /device2_reg/, ...}
#     You may register devices for custom behavior by device.
#     Once a device is registered you may call the helper request_device?(device_symb)
#     to see if the request comes from that device or not.
#     By default :iphone, :ipad, :ios and :android are already registered.
# * skip_user_agents: [:ipad, :android]
#     Don't consider these user agents mobile devices.
#
# Example Usage:
#
#   class ApplicationController...
#     include Mobylette::RespondToMobileRequests
#     ...
#     mobylette_config do |config|
#       config[:fall_back] = :html
#       config[:skip_xhr_requests] = false
#       config[:mobile_user_agents] = proc { %r{iphone|android}i }
#       config[:devices] = {cool_phone: %r{cool\s+phone} }
#     end
#     ...
#   end
#
This method enables the controller do handle mobile requests
You must add this to every controller you want to respond differently to mobile devices,
or make it application wide calling it from the ApplicationController

Possible options:
fall_back: :html
You may pass a fall_back option to the method, it will force the render
to look for that other format, in case there is not a .mobile file for the view.
By default, it will fall back to the html format.
If you don't want fall back at all, pass fall_back: false
skip_xhr_requests: true/false
By default this is set to true. When a xhr request enters in, it will skip the
mobile verification. This will let your ajax calls to work as intended.
You may disable this (actually you will have to) if you are using JQuery Mobile, or
other js framework that uses ajax. To disable, set skip_xhr_requests: false
mobile_user_agents: proc { /user_agents_match/ }
If you want to restrict the user agents that will be considered mobile devices,
you can send a custom proc/object that returns the matching regex you wish.
devices: {device_name: /device_reg/, device2_name: /device2_reg/, ...}
You may register devices for custom behavior by device.
Once a device is registered you may call the helper request_device?(device_symb)
to see if the request comes from that device or not.
By default :iphone, :ipad, :ios and :android are already registered.
skip_user_agents: [:ipad, :android]
Don't consider these user agents mobile devices.

Example Usage.


This method enables the controller do handle mobile requests You must add this to every controller you want to respond differently to mobile devices or make it application wide calling it from the ApplicationController Possible options : fall_back : : html You may pass a fall_back option to the method it will force the render to look for that other format in case there is not a . mobile file for the view . By default it will fall back to the html format . If you don ' t want fall back at all pass fall_back : false skip_xhr_requests : true / false By default this is set to true . When a xhr request enters in it will skip the mobile verification . This will let your ajax calls to work as intended . You may disable this ( actually you will have to ) if you are using JQuery Mobile or other js framework that uses ajax . To disable set skip_xhr_requests : false mobile_user_agents : proc { / user_agents_match / } If you want to restrict the user agents that will be considered mobile devices you can send a custom proc / object that returns the matching regex you wish . devices : { device_name : / device_reg / device2_name : / device2_reg / ... } You may register devices for custom behavior by device . Once a device is registered you may call the helper request_device? ( device_symb ) to see if the request comes from that device or not . By default : iphone : ipad : ios and : android are already registered . skip_user_agents : [ : ipad : android ] Don ' t consider these user agents mobile devices . Example Usage .
def mobylette_config
        yield(self.mobylette_options)
        configure_fallback_resolver(self.mobylette_options)
        Mobylette.devices.register(self.mobylette_options[:devices]) if self.mobylette_options[:devices]
      end
def mobylette_config yield ( self . mobylette_options ) configure_fallback_resolver ( self . mobylette_options ) Mobylette . devices . register ( self . mobylette_options [ :devices ] ) if self . mobylette_options [ :devices ] end
This method enables the controller do handle mobile requests
You must add this to every controller you want to respond differently to mobile devices,
or make it application wide calling it from the ApplicationController
This method enables the controller do handle mobile requests You must add this to every controller you want to respond differently to mobile devices or make it application wide calling it from the ApplicationController