How to disable IE6 in your Rails applications

Well, the uprising against IE 6 has begun, and not a moment too soon – IE 6 will be seven years old on August 27th. In fact, there’s even a service to say goodbye to the old dinosaur.

You can do your bit for the Internet by showing a warning to IE 6 users in your Rails applications, or disabling it completely for those users, encouraging them to upgrade their browsers (or nag the relevant Sys Admin).

Firstly you need to install the UserAgent plugin by Josh Peek:
script/plugin install git://github.com/josh/useragent.git

You then need to copy this script to your lib directory.

If you want to just show a warning to people using unsupported browsers, you’ve got a valid_browser? helper method:
<%- unless valid_browser? -%> ... <%- end -%>

Or you can disable access completely:

before_filter :restrict_browser
def restrict_browser
unless valid_browser?
render :action => '/path_to_template'
return false
end
end

See also:

  • No similar posts

About the author

  • Comments (1)

    1. I’m all in favour of the idea. If you just want to show a warning, conditional comments are simpler and more reliable than server-side user agent sniffing. They also avoid any caching complexity. The only downside is that they appear in the source of every page as comments.

  • Responses (0)

Leave a comment

Our latest tweets

Categories

Recent comments

  • Justin McMurray: I kinda wish I had gone to this panel now :) I've seen these techniques employed (ahem, in both d...
  • richard helyar: you're forgetting one critical element: the average viewer (remember, you do not represent the avera...
  • Azizuan: thanks for the tips...
  • scottwgray: If Clay really wants to advance the careers of talented women, why doesn't he simply adopt a policy ...
  • Joseph Kingsbury, Text 100: Isaac, interesting take on this, your honesty is refreshing. clearly nobody wants to listen to peopl...