This is a generic question but I''ll use Globalize as the example. On each page request a class method is called on Locale to set the page locale from the url - eg ..../en/index... would be en=english. I later perform some application specific logic based on the value of the Locale class. Now if two people are hitting the webserver at the same time are their Locales going to get intertwined? Or does a seperate class get created for every visitor? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Oct 29, 2006, at 2:24 AM, George Palmer wrote:> > This is a generic question but I''ll use Globalize as the example. On > each page request a class method is called on Locale to set the page > locale from the url - eg ..../en/index... would be en=english. I > later > perform some application specific logic based on the value of the > Locale > class. > > Now if two people are hitting the webserver at the same time are their > Locales going to get intertwined? Or does a seperate class get > created > for every visitor? > >Hey George- A new controller class is instantiated for each request. But class variables are global for the whole inheritance chain of classes that contain them. And rails is not thread safe so there is always a mutex that ensures that only one request is ever running through the rails dispatcher at once. So as long as you make absolutely certain that the @@classvariable gets set on each and every request, you will not run into any problems. Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Awesome thanks Ezra, the class variable is always set on each request. If you''re running say 20 FastCGI proccesses do they each run their own ruby instance or are they all using one ruby instance with locking as you described? Just checked out your hosting btw - looks pretty good! Ezra Zygmuntowicz wrote:> On Oct 29, 2006, at 2:24 AM, George Palmer wrote: > >> Locales going to get intertwined? Or does a seperate class get >> created >> for every visitor? >> >> > > Hey George- > > > A new controller class is instantiated for each request. But class > variables are global for the whole inheritance chain of classes that > contain them. And rails is not thread safe so there is always a mutex > that ensures that only one request is ever running through the rails > dispatcher at once. So as long as you make absolutely certain that > the @@classvariable gets set on each and every request, you will not > run into any problems. > > Cheers- > -- Ezra Zygmuntowicz > -- Lead Rails Evangelist > -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273)-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hi~ On Oct 29, 2006, at 12:12 PM, George Palmer wrote:> > Awesome thanks Ezra, the class variable is always set on each request. > If you''re running say 20 FastCGI proccesses do they each run their own > ruby instance or are they all using one ruby instance with locking as > you described?Yes, each fcgi or mongrel backend runs a copy of rails in its own ruby process/interpreter.> > Just checked out your hosting btw - looks pretty good!Thanks! -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---