0

Is there any really easy way to get to know, what browser has called controller's action.

I would like to have a code for my controller, like this:

if mighty_lib.browser.name == "Safari"
   if mighty_lib.browser.version >= 5
       # Glad to see you, Safari 5, there is a stunning, interactive page for you.
   elsif mighty_lib.browser.version >= 4
       # Glad to see you, Safari 4, there is a less advanced page for you.
   end
if mighty_lib.browser.name == "Firefox"
   # Quick brown fox jumps over the lazy dog
elsif mighty_lib.browser.name == "IE"
   # Oh, my god ... Change your browser ! There is a "Jurassic Park" movie for you
end
4

3 回答 3

2

我建议服务器不是处理不同浏览器需求的最佳位置 - 它通常是使用智能 css 和(不显眼的)javascript 根据特定功能在客户端打开和关闭功能的更好方法客户端而不是修复特定版本。

于 2010-08-24T11:27:59.503 回答
1

我发现了两个可以完成工作的宝石:

https://github.com/kevinelliott/agent_orange

https://github.com/visionmedia/user-agent

于 2012-04-25T20:49:38.207 回答
0

您可以使用这个旧插件,或者编写一些使用request.env["HTTP_USER_AGENT"]. 另外,请查看Ruby 论坛上的此评论。

于 2010-08-24T11:08:35.243 回答