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

  • James Higgs: At some level Kujau wanted the attention, and the same seems to be true of Manning if he is indeed t...
  • William Owen: Sara, you've asked lots of pertinent questions here but I think you’re really asking quite a lot of ...
  • Sara Williams: James, as much as I want to agree with you -- you are right a very good percentage of the time -- th...
  • James Higgs: There is a certain logic to this: people are unlikely to go through a great deal of effo...
  • Tim Malbon: I think we should remember that we are in Afghanistan because its leaders allowed it to be used as a...