Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to detect user agent in Rails 3.1 [duplicate]

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!

like image 361
Daniël Zwijnenburg Avatar asked Oct 04 '11 16:10

Daniël Zwijnenburg


2 Answers

Yep, just use this

request.env["HTTP_USER_AGENT"] #or request.user_agent 
like image 187
CambridgeMike Avatar answered Sep 20 '22 15:09

CambridgeMike


What about using a simple gem?

If I remember well, I used this one last time.

gem install user-agent

The same one on GitHub

I think that this is a good way to do it...

like image 38
Nicolas Guillaume Avatar answered Sep 16 '22 15:09

Nicolas Guillaume