Module: IsItMobile::ForRails

Defined in:
lib/is_it_mobile.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

When ForRails is included in a controller, a before filter is added that will reset the request format to the value of base.mobile_format which defaults to :mobile. To change it to something else, simply add a line after the inclusion that says self.mobile_format = :handheld or whatever you’d like it to be.

It also exposes the request_is_from_mobile? method to the views if you don’t want to create multiple erb views for every page (or want to keep a single layout file)



20
21
22
23
24
25
26
27
28
29
# File 'lib/is_it_mobile.rb', line 20

def self.included(base)
  base.class_eval do
    class_inheritable_accessor :mobile_format
    self.mobile_format = :mobile
    
    before_filter :wrangle_format_if_request_is_mobile
    
    helper_method :request_is_from_mobile?
  end
end