Does it make sense to make a singleton class in Rails? I made a singelton class but everytime I do model.instance.id in some controller it is always different. Is this because it is in development mode so the classes get reloaded each time but in production this would not be the case? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
The short and sweet: you can not, should not, and will not try to save information in memory in your Rails environment across web requests. If you need to save data, use a database, use the session, use flat files on the disk. Expecting Ruby to "just remember" is pointless here because 1) yes, development environment reloads everything on each request and 2) production deploy environments run mutiple instances of Rails processes so you''re never guarenteed to get the same process for subsequent requests. Jason On Fri, Jan 30, 2009 at 2:43 PM, Ball Balla <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Does it make sense to make a singleton class in Rails? I made a > singelton class but everytime I do model.instance.id in some controller > it is always different. Is this because it is in development mode so the > classes get reloaded each time but in production this would not be the > case? > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks jason. Question on part 2) Say I have only 1 production box with 4 mongrels on it. Wouldnt there only be 4 rails processes? Or does each mongrel have many rails processes running? Do you know of any documentation that explains all of this? Thanks Jason Roelofs wrote:> The short and sweet: you can not, should not, and will not try to save > information in memory in your Rails environment across web requests. > If you need to save data, use a database, use the session, use flat > files on the disk. Expecting Ruby to "just remember" is pointless here > because 1) yes, development environment reloads everything on each > request and 2) production deploy environments run mutiple instances of > Rails processes so you''re never guarenteed to get the same process for > subsequent requests. > > Jason > > On Fri, Jan 30, 2009 at 2:43 PM, Ball Balla-- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Rails deployment is a huge subject, though in short if you were to use Mongrel you''d have your HTTP server in front (Apache / nginx / etc) proxy out to a cluster of mongrels. Thus, each mongrel is a Rails process. Personally, I''d say to forego Mongrels / Thins / etc and check out Passenger: http://www.modrails.com (which does the same thing, proxying off to Rails processes, but it''s all hidden from you). Jason On Fri, Jan 30, 2009 at 3:20 PM, Ball Balla <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Thanks jason. Question on part 2) > > Say I have only 1 production box with 4 mongrels on it. Wouldnt there > only be 4 rails processes? Or does each mongrel have many rails > processes running? Do you know of any documentation that explains all of > this? Thanks > > Jason Roelofs wrote: >> The short and sweet: you can not, should not, and will not try to save >> information in memory in your Rails environment across web requests. >> If you need to save data, use a database, use the session, use flat >> files on the disk. Expecting Ruby to "just remember" is pointless here >> because 1) yes, development environment reloads everything on each >> request and 2) production deploy environments run mutiple instances of >> Rails processes so you''re never guarenteed to get the same process for >> subsequent requests. >> >> Jason >> >> On Fri, Jan 30, 2009 at 2:43 PM, Ball Balla > > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---