Find Web browser user agent using rails 3


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:

This slideshow requires JavaScript.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s