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

1 comment
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.