Quantcast
Channel: my linux world » postaweek2011
Viewing all articles
Browse latest Browse all 10

Find Web browser user agent using rails 3

$
0
0

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.

Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images