Forum: Ruby on Rails Browser Detection

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Thiago J. (Guest)
on 2006-02-08 00:50
(Received via mailing list)
How can I detect the user's browser in Rails?

Kent S. (Guest)
on 2006-02-08 01:02
(Received via mailing list)

Dave S. (Guest)
on 2006-02-08 13:43
(Received via mailing list)
On Tuesday 07 Feb 2006 23:01, Kent S. wrote:
> request.user_agent

Though please use that with extreme care and discretion, Thiago -
sniffing based on user-agent string is generally a very bad idea.  I'm
saying you're *definitely* doing it the wrong way (since I don't know
you're trying to do), but chances are there's a better way you can solve
almost any scenario where user-agent detection used to be the accepted
solution a few years back.

Server-side user-agent sniffing in particular... if you're using that to
up different versions of pages to different browsers, please seriously
reconsider!  The only thing I would use server side UA detection for
days is something like error log generation for the site owner.
Public-facing server-side UA detection is a big no-no, as far as I'm
concerned - it doesn't work, unnecessarily hurts users, isn't future
and basically isn't even particularly necessary in the first place.

If you code to web standards, there are a lot of easy methods you can
use to
make your site gracefully degrade for non-standards compliant (eg.
or Microsoft written, hehehe!) browsers.  I don't want to go into too
detail here, because I hope you already know most of these techniques.
not, a good place to start is...

... which is one of the best web development books I ever bought.

All I wanted to say is that whenever anyone mentions browser detection,
especially server side, my alarm bells go off!!  So I hope you are using
for the right reasons, and if so, please accept my apologies for the
unwarranted concern!




Dave S.
Rent-A-Monkey Website Development

PGP Key:
This topic is locked and can not be replied to.