Hi friends,
In rails 3 there is a easy way to Detect the web browser user agent .
By adding the one line in the controller page, we can get the UA.(@user_agent = request.env['HTTP_USER_AGENT'])
In /app/controllers/users_controller.rb
def index @users = User.all @user_agent = request.env['HTTP_USER_AGENT']
In /app/views/users/index.html.erb
<%= @user_agent %>
That’s All !!!
GitHub Link: https://github.com/thasuresh/find_user_agent
Live Example On Heroku: http://findua.heroku.com/
Ex snaps for various Web browsers:
Click to view slideshow.