Skip to content

Instantly share code, notes, and snippets.

@moudy
Created March 18, 2013 15:35
Show Gist options
  • Save moudy/5188040 to your computer and use it in GitHub Desktop.
Save moudy/5188040 to your computer and use it in GitHub Desktop.
# Detect unsuppoerted browsers exculding crawlers and chrome frame
# browser gem - https://github.com/fnando/browser
def is_unsupported_browser?
is_ie = browser.ie6? || browser.ie7? || browser.ie8?
is_firefox36 = browser.firefox? && browser.full_version.match(/^3.6.*/)
is_crawler = request.env["HTTP_USER_AGENT"].match(/\(.*https?:\/\/.*\)/) if request.env["HTTP_USER_AGENT"]
has_chrome_frame = request.env["HTTP_USER_AGENT"].match(/chromeframe/) if request.env["HTTP_USER_AGENT"]
return !has_chrome_frame && (is_ie || is_firefox36) unless is_crawler
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment