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

我们两清 提交于 2019-12-20 10:18:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!