On 24 February 2016 at 17:07, Gm <javaplayer@gmail.com> wrote:
> Sorry Colin,
>
> Actually I need help about how can I run a background job.
> This job needs to listen all events registered in database and send an email
> when the dates match.
>
> I'm found clockwork gem as an option to do this.
> I have to create a worker that runs every minute and verifies if current
> date/time is the same from the event in the database.
> Is it a good alternative ?
Well you can tell us that. If it working well and was easy to
implement then yes.
I don't know how you have coded it but a suggestion is to put all the
logic in a method of one (or more) of the models and then just call
that from the worker. That way the code is easier to test using your
automated tests.
I would probably just have written a rake task and called it from
cron, but I have not tried the clockwork gem so maybe it is a good
alternative. Does it play well with rails? I notice that it has not
been updated for a year or so, but maybe that is not an issue.
Colin
>
> Thanks.
>
> On Wednesday, February 24, 2016 at 2:02:24 PM UTC-3, Colin Law wrote:
>>
>> On 24 February 2016 at 16:38, Gm <javap...@gmail.com> wrote:
>> > Hi,
>> >
>> > I need some help to schedule some tasks.
>> > I have a database table with a column called: start
>> >
>> > I need to send an email and update a column at that start date.
>> > How can I iterate my database table, verify if today has some tasks to
>> > be
>> > executed and send an email.
>>
>> You have described a problem with a large number of aspects. Which
>> particular bit do you not know how to do? Running a background job?
>> Iterating the table? Testing whether you have to do something?
>> Sending the email? Updating the database? Anything else?
>>
>> Colin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/e75b34b2-eeab-42f7-be7d-68a67776090b%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtEfNJK7smV5q3YyDu_LXfzA6zRr4xzyqSpPxe2Nxacag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment