Active_record + threads

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 * FROMteamsWHERE ( 2) (ActiveRecord::StatementInvalid) from simm.rb:311:injoin’
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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs