I know, that my question is easy for you, but not for me, because I’m
beginner with RoR.
My application sends a lot of emails - not only for confirm
registration, change password, but others. I take time if I do this by
My application also creates many files - it takes a time too…
Is there a good way for sending email in background?
Is there a good way for scheduling jobs?
Thanks for help?
Two best I have personally found are backgroundrb and spawn:
With spawn, scheduling a background (deferred) task is about as simple
as can be:
# do whatever you want in here (rails environment is loaded)
If you want recurring job or more finetuned control, you can use
backgroundrb which is as simple as
- generate a worker
- code the worker to do a task
- Invoke the worker task with the syntax (roughly):
I found this:
railspikes.com - This website is for sale! - railspikes Resources and Information.,
It’s interesting, but not everything is clear for me…
Maybe someone know more about this solutions?
Nathan - spawn works perfect
Thanks a lot!
Do you know something about cornedit?
Emails are really sent in the background since they will be queued by
sendmail or similar. If you plan on sending a ton of emails in one
request, I would suggest setting something up with crontab to execute at
You can create a model and put your logic in there and then add a
class MyScriptModel < ActiveRecord::Base
Generate all the emails here
0 * * * * some_user RAILS_ROOT/script/runner MyScriptModel.some_method
Something along these lines should get you started.
There are certainly other solutions, but I think this would be fairly
easy to get going.
-----BEGIN PGP SIGNED MESSAGE-----
On Thursday 05 June 2008 09:06:22 Anka Gr wrote:
Generally the idea is clear, but tell me, how my some_method invoked
in crontab knows which email should be send?
Should I use e.g. table jobs, where I put information which email and
to whom it should me send? And some_method should checking this jobs?
That’s usually what I do when cron is sufficient, yes. I like
the “queued_” prefix for table names for this kind of thing,
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
-----END PGP SIGNATURE-----
I said, that emails are sent in the background so why request is longer
than when I use spawn? It can be other reason?
and question about crontab:
Generally the idea is clear, but tell me, how my some_method invoked in
crontab knows which email should be send?
Should I use e.g. table jobs, where I put information which email and to
whom it should me send? And some_method should checking this jobs?
It’s hard to explain and asking in English