Module: MobileView::ControllerAdditions::ClassMethods

Defined in:
lib/mobile_view/controller_additions.rb

Instance Method Summary collapse

Instance Method Details

#has_mobile_viewObject

Install MobileView into a Controller.

By invoking this method, a view-path resolver will be prepended before all the existing resolvers, immediately. If you’re going to force mobile switching (see ForcedSwitching), then you have to invoke them before has_mobile_view.

Example

Present non-mobile version to iPad users:

class ApplicationController < ActionController::Base
  before_filter :force_non_mobile!, :if => :ipad?

  has_mobile_view
end


34
35
36
37
38
39
40
# File 'lib/mobile_view/controller_additions.rb', line 34

def has_mobile_view

  # find mobile view templates first, if mobile device is detected.
  self.before_filter do
    prepend_view_path(MobileView.resolver) if mobile?
  end
end