Reputation: 3233
In my rails application (rails version is 2.3.12), i am using thread for sending mails like below
Thread.new{SomeMailer.deliver_method(stuff)}
How to test this thread in rails. Actually i wrote this line in model.
Thanks in advance, Jak.
Upvotes: 4
Views: 265
Reputation: 8400
In general, don't use threads in Rails. Use a single thread per process and use background workers to do stuff like this. Popular workers include delayed_job and resque.
In delayed_job:
SomeMailer.delay.deliver_method(stuff)
In Resque:
class DeliverStuff
@queue = :mail
def self.perform(stuff)
SomeMailer.deliver_method(stuff)
end
end
# elsewhere
Resque.enqueue(DeliverStuff, stuff)
Upvotes: 2