Hi all, I would like to have a connection-per-thread in my rails app. According to the base.rb file, @@allow_concurrency parameter mustbe set to true. I tried setting it both in environment.rb and ApplicationController but did not work. Where should I change that parameter so that it can work? Thanks. Ayhan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That kind of configuration should go in config/environment.rb, though you can''t just do ''@@allow_concurrency = true'' in the Initializer block. I''m not sure where this var is, I think ActiveRecord, so this would be the line you add (I''m pretty sure): Rails::Initializer do ... config.active_record.allow_concurency = true ... end Jason On 8/28/06, amolla <amolla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi all, > I would like to have a connection-per-thread in my rails app. According > to the base.rb file, @@allow_concurrency parameter mustbe set to true. > I tried setting it both in environment.rb and ApplicationController but > did not work. Where should I change that parameter so that it can work? > > Thanks. > > Ayhan > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Aug 28, 2006, at 7:59 AM, Jason Roelofs wrote:> That kind of configuration should go in config/environment.rb, > though you can''t just do ''@@allow_concurrency = true'' in the > Initializer block. I''m not sure where this var is, I think > ActiveRecord, so this would be the line you add (I''m pretty sure): > > Rails::Initializer do > ... > config.active_record.allow_concurency = true > ... > end > > Jason > > On 8/28/06, amolla < amolla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi all, > I would like to have a connection-per-thread in my rails app. > According > to the base.rb file, @@allow_concurrency parameter mustbe set to true. > I tried setting it both in environment.rb and ApplicationController > but > did not work. Where should I change that parameter so that it can > work? > > Thanks. > > Ayhan >Can you explain what you mean by "I would like to have a connection- per-thread in my rails app" ? Rails doesn''t work that way as th framework as a whole is not thread safe> So when it is served by mongrel , webrick or fcgi, requests are serialized when they are dispatched to rails so that only one runs at a time. So setting allow_concurrency= true in a normal rails app will not get you anything. If you explain what you are trying to do I amy be able to shed some more light on it for you.; -Ezra --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for your replies. In my tests in webrick server I found that all the threads are sharing a single database conenction. But I would like each thread to have its own connection. I solved that with Jason''s advice by doing the the following in environment.rb Rails::Initializer.run do |config| config.active_record.allow_concurrency = true end Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---