Hi all how can I implement the singleton patter in RoR? thanks -- 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 16, 2006, at 22:10, Jose Pepe wrote:> Hi all > > how can I implement the singleton patter in RoR?include Singleton -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ 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 Jose, The Singleton module that Jakob mentioned comes with Ruby, not rails. You can read about it in the ruby docs. Cheers Starr --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Starr wrote:> Hi Jose, > > > The Singleton module that Jakob mentioned comes with Ruby, not rails. > You can read about it in the ruby docs.Be aware that a Rails application that needs to handle concurrent requests will do that by having multiple server processes (Mongrel, FastCGI, SCGI, ...) behind a web server or load balancer. Each server process will have its own singleton instance. That is OK if you just want a singleton holding fixed data, but won''t allow you to share dynamic application state between requests and sessions. regards Justin Forder --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Justin Forder wrote:> Starr wrote: >> Hi Jose, >> >> >> The Singleton module that Jakob mentioned comes with Ruby, not rails. >> You can read about it in the ruby docs. > > Be aware that a Rails application that needs to handle concurrent > requests will do that by having multiple server processes (Mongrel, > FastCGI, SCGI, ...) behind a web server or load balancer. Each server > process will have its own singleton instance. That is OK if you just > want a singleton holding fixed data, but won''t allow you to share > dynamic application state between requests and sessions. > > regards > > Justin ForderHi Justin, 2 years later ... I''m looking for a non dirty way to implement a view with a progress bar who indicates the status of a certain task who takes some time to achieive. The task will be lunched in a thread. I first tried using a singleton class with the thread as an instance variable, but I realized that a different server thread serves each request, and so has one instance of the singleton. So it''s not a good option. Does anybody know how I should implement something like that ? I done it before passing by a file on disk to get the status of the thread. I posted a more detailed question here : http://railsforum.com/viewtopic.php?pid=101201#p101201 Thanks -- Posted via http://www.ruby-forum.com/.