Forum: Ruby on Rails active_record + threads

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Javier 1. (Guest)
on 2008-12-18 14:00
I'm having problems with active_record within threads

I have some code that works alone, but if I insert it into a thread

threads = []
for x in 1..5 do
   threads << do
      team = Team.find(2)

threads.each do |t|

That code fails with:

`log': Mysql::Error: Lost connection to MySQL server during query:
SELECT * FROM `teams`     WHERE (`teams`.`id` = 2)
  from simm.rb:311:in `join'
  from simm.rb:311
  from simm.rb:310:in `each'
  from simm.rb:310

Seems the connection goes away inside threads, isn't it?
It works without threads...
This topic is locked and can not be replied to.