Best bet is to put the user agent string through a RegExp. The  
following has worked for me and generates a two-letter country code:

request.env['HTTP_USER_AGENT'][/\((.*;)+.*(\S*?)\)/,2][0..1]

Cheers,

Josh

On Nov 25, 2008, at 11:45 AM, CiriusMex wrote:

> Hi folks ^^
>
> Here is my problem. I have a page on my RoR site which display prices.
> The idea is to display those prices in the currency corresponding to
> the user country. I already have a table in my database with the
> currency in function of the country and I implemented the convertion
> module (using Yahoo Finance plugin, works really great!).
> My problem is how do I do to access user's browser parameters in order
> to get the country parameter?
> I know it can be done in the most part of the languages (such as Java
> and ASP.net) so I hope it can be done with RoR too...Checked on google
> and didn't find anything interesting on the subject.
>
> Thanks in advance for the help.
>
> Have a good day,
> Olivier.
>