Is there a way to detect user agent in Rails 3.1
22,927
Solution 1
Yep, just use this
request.env["HTTP_USER_AGENT"]
#or
request.user_agent
Solution 2
What about using a simple gem?
If I remember well, I used this one last time.
gem install user-agent
I think that this is a good way to do it...
Author by
Daniël Zwijnenburg
Freelance | Elixir | Ruby | Javascript | Devops
Updated on September 09, 2020Comments
-
Daniël Zwijnenburg almost 4 years
Possible Duplicate:
Auto detect mobile browser (via user-agent?)
Rails 3: HTTP_USER_AGENTIs 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!
-
Nicolas Guillaume over 12 yearsI'm not sure that we can call that a "solid way" :p
-
f0ster almost 11 yearsLOL there's a gem for that.
-
Franklin Yu almost 8 yearsThat's a quite old gem which does not even include Windows 8, and it has only one single release on RubyGems. I would suggest
useragent
with operating system support up to Windows 10.