Locale model to store language value not working


I have a problem to store the current locale (language) used by a user .

I have this model that represent the locale:

class LocaleModel < ActiveRecord::Base   @@global_locale = nil

  def self.global     @@global_locale   end

  def self.global=( locale )     if locale.is_a? Locale       @@global_locale = locale     elsif locale.is_a? String       locale = LocaleModel.find(:first, :conditions => ['short = ? ', locale])       return false if (! locale)       @@global_locale = locale     else       # empty       @@global_locale = nil     end   end

  def master?     self.master == true   end end

In my application controller I do :

LocaleModel.global = 'fr' if LocaleModel.global == nil

And in some other controller I have an action that is used to change the locale:

def change_locale      LocaleModel.global = params[:lang] end

The problem is that when I change the view or reload the page, the locale always resets. How come ?

Thank You