问题
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!
回答1:
Yep, just use this
request.env["HTTP_USER_AGENT"]
#or
request.user_agent
回答2:
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...
回答3:
you can do it also client site with jquery ... there is a plugin
http://plugins.jquery.com/project/client-detect
来源:https://stackoverflow.com/questions/7650799/is-there-a-way-to-detect-user-agent-in-rails-3-1