Created
February 8, 2010 15:05
-
-
Save jalberto/298211 to your computer and use it in GitHub Desktop.
This file contains 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
# 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