Created
November 10, 2011 10:03
-
-
Save vincentpaca/1354531 to your computer and use it in GitHub Desktop.
Application Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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