# Problem in backgroundrb

**URL:** <https://www.ruby-forum.com/t/problem-in-backgroundrb/88524>\
**Category:** Rails\
**Created:** [March 12, 2007, 11:23am UTC](https://www.ruby-forum.com/t/problem-in-backgroundrb/88524 "2007-03-12T11:23:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![selvaraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@selvaraj](https://www.ruby-forum.com/u/selvaraj)\
**Post date:** [March 12, 2007, 11:23am UTC](https://www.ruby-forum.com/t/problem-in-backgroundrb/88524/1 "2007-03-12T11:23:19Z")

</div>

Here my code

class SendMessageWorker \< BackgrounDRb::Worker::RailsBase

def do\_work(args)  
# This method is called in it’s own new thread when you  
# call new worker. args is set to :args  
@sms2=SendMessageDetail.find\_by\_send\_message\_id(args)  
@sms2.each do |send\_msg| @sms2  
.  
.  
…  
some of my logic  
end

problem is for loop…  
if i excute this code, its telling each is undifined methiod.

If i am executing without for loop its working fine.

please help me…

---

<div class="post-metadata">

**Author:** ![selvaraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@selvaraj](https://www.ruby-forum.com/u/selvaraj)\
**Post date:** [March 12, 2007, 11:49am UTC](https://www.ruby-forum.com/t/problem-in-backgroundrb/88524/2 "2007-03-12T11:49:11Z")

</div>

On 12 Mar 2007, at 10:23, selvaraj wrote:

> ```
> .
> .
> ...
> some of my logic
> end
> 
> ```
> 
> problem is for loop…  
> if i excute this code, its telling each is undifined methiod.
> 
> If i am executing without for loop its working fine.

I think you want find\__all_\_by\_send\_message\_id

---

<div class="post-metadata">

**Author:** ![selvaraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@selvaraj](https://www.ruby-forum.com/u/selvaraj)\
**Post date:** [March 12, 2007, 11:55am UTC](https://www.ruby-forum.com/t/problem-in-backgroundrb/88524/3 "2007-03-12T11:55:52Z")

</div>

Jonathan del Strother wrote:

> On 12 Mar 2007, at 10:23, selvaraj wrote:
> 
> > ```
> > .
> > .
> > ...
> > some of my logic
> > end
> > 
> > ```
> > 
> > problem is for loop…  
> > if i excute this code, its telling each is undifined methiod.
> > 
> > If i am executing without for loop its working fine.
> 
> I think you want find\__all_\_by\_send\_message\_id

ya i got it.

many thanks for yr reply
