# Database access in a thread

**URL:** <https://www.ruby-forum.com/t/database-access-in-a-thread/133045>\
**Category:** Rails\
**Created:** [March 27, 2008, 1:32am UTC](https://www.ruby-forum.com/t/database-access-in-a-thread/133045 "2008-03-27T01:32:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e47774/32.png) [@vikram](https://www.ruby-forum.com/u/vikram)\
**Post date:** [March 27, 2008, 1:32am UTC](https://www.ruby-forum.com/t/database-access-in-a-thread/133045/1 "2008-03-27T01:32:11Z")

</div>

Hi all,

Even after setting ActiveRecord::Base.allow\_concurrency = true in my  
controller, I can’t access the database in a new thread that I create  
within that controller.

I am trying to start a new thread in my controller after sending out an  
email. If after 5 minutes of sending out that email, a response is not  
detected (by way of a flag in the database), I need to reset that flag.  
So my new thread will sleep for 5 minutes and then check the database  
and take the necessary actions.

BackgroundRB seems way too complicated for such a task.

This seems such an easy thing to do in Java and other languages but has  
got me stumped here. I have trawled the Internet and looked up all sorts  
of books, to no avail!

Any help appreciated.

Vikram
