Skip to content

Instantly share code, notes, and snippets.

@vincentpaca
Created November 10, 2011 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentpaca/1354531 to your computer and use it in GitHub Desktop.
Save vincentpaca/1354531 to your computer and use it in GitHub Desktop.
Application Controller
before_filter :prepare_for_mobile
private
def mobile_device?
if session[:mobile_param]
session[:mobile_param] == "1"
else
request.user_agent =~ /Mobile|webOS/
end
end
helper_method :mobile_device?
def prepare_for_mobile
if request.format == 'text/html'
session[:mobile_param] = params[:mobile] if params[:mobile]
request.format = :mobile if mobile_device?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment