hi

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
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to