Skip to content

JQuery mobile and mobile fu

houen edited this page Nov 24, 2011 · 4 revisions

If using the awesome jQuery Mobile, you should add this to your ApplicationController:

before_filter :set_request_format
def set_request_format
  request.format = :mobile if is_mobile_device?
end

So it now looks like this:

class ApplicationController < ActionController::Base
  protect_from_forgery
  has_mobile_fu # Detect the device type
  before_filter :set_request_format

  def set_request_format
    request.format = :mobile if is_mobile_device?
  end
end

A great thanks to dmfrancisco for saving my bacon with this :-)

Clone this wiki locally