Is there a way to detect user agent in Rails 3.1

Daniël Zwijnenburg picture Daniël Zwijnenburg · Oct 4, 2011 · Viewed 22.7k times · Source

Possible Duplicate:
Auto detect mobile browser (via user-agent?)
Rails 3: HTTP_USER_AGENT

Is there a way to detect the user agent from a current visitor? I'm currently working on a project to display video files. But for the ipad, iphone / samsung galaxy tab / internet explorer / firefox. I need to display video's is there a solid way to check which browser is visiting my rails app?

Thanks guys!

Answer

CambridgeMike picture CambridgeMike · Oct 4, 2011

Yep, just use this

request.env["HTTP_USER_AGENT"]
#or
request.user_agent