Reputation: 17430
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
Upvotes: 0
Views: 1288
Reputation: 5224
I found two gem that can make the work:
https://github.com/kevinelliott/agent_orange
https://github.com/visionmedia/user-agent
Upvotes: 1
Reputation: 37143
I would suggest that the server is not the best place to handle different browser requirements - it is generally a much better approach to use smart css and (unobtrusive) javascript to turn features on and off on the client-side according to the specific capabilities of the client as opposed to fixing on specific versions.
Upvotes: 2
Reputation: 13438
You may use this old plugin, or write some raw code that uses request.env["HTTP_USER_AGENT"]
. Also, take a look at this comment at Ruby forums.
Upvotes: 0