Skip to content

Instantly share code, notes, and snippets.

@jalberto
Created February 8, 2010 15:05
Show Gist options
  • Save jalberto/298211 to your computer and use it in GitHub Desktop.
Save jalberto/298211 to your computer and use it in GitHub Desktop.
# Detects user's browser.
def browser_name
ua = request.user_agent.downcase
if ua =~ /firefox\//
:firefox
elsif ua =~ /opera\//
:opera
elsif ua =~ /chrome\//
:chrome
elsif ua =~ /safari\//
:safari
elsif ua =~ /msie/
:ie
else
nil
end
end
def browser_is? name
browser_name == name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment