How to detect browser type and its version

how can i detect browser type and its version in Rails. I want to put check on the version of specific browser and if its not required browser version than ask user to upgrade it.. i use below spec...