I have a subscription-based site that allows unregistered users to download files if they give me their email. I want the following workflow.
我有一个基于订阅的网站,允许未注册的用户下载文件,如果他们给我他们的电子邮件。我想要以下工作流程。
-
User give email address
用户提供电子邮件地址
-
Rails creates a task for 7 days in the future
Rails将来会创建一个任务7天
-
User downloads emailed file
用户下载电子邮件文件
-
If user hasn't signed up in 7 days, send user an email
如果用户未在7天内注册,请向用户发送电子邮件
I need to add #2 and #4. Right now I'm using ActiveJob and Sidekiq to create jobs to send the download email. Is there a way I can create an ActiveJob to run in the future? And will that future job have access to my rails environment to check against my DB?
我需要添加#2和#4。现在我正在使用ActiveJob和Sidekiq创建作业以发送下载电子邮件。有没有办法让我可以创建一个ActiveJob来运行?未来的工作是否可以访问我的rails环境以检查我的数据库?
2 个解决方案
#1
1
Sure you can enqueue an ActiveJob to be performed in 1 week. In the job's implementation conditionally send an email if the user hasn't signed up. Refer to the Rails guides on ActiveJob: http://guides.rubyonrails.org/active_job_basics.html#enqueue-the-job
当然,您可以在一周内将ActiveJob排队。在作业的实施中,如果用户尚未注册,则有条件地发送电子邮件。请参阅ActiveJob上的Rails指南:http://guides.rubyonrails.org/active_job_basics.html#enqueue-the-job
Example:
例:
# Enqueue a job to be performed 1 week from now.
UserConfirmationJob.set(wait: 1.week).perform_later(user)
#2
0
Can you do it this way:
你能这样做吗:
- User gives the email.
- 用户发送电子邮件。
- You allow him to download.
- 你允许他下载。
- Every day you run a script to check that whether the user who gave his email 7 days ago has signed up or not.
- 您每天都会运行一个脚本来检查7天前发送电子邮件的用户是否已注册。
- And you send him an email if he hasn't signed up.
- 如果他还没有注册,你就给他发电子邮件。
#1
1
Sure you can enqueue an ActiveJob to be performed in 1 week. In the job's implementation conditionally send an email if the user hasn't signed up. Refer to the Rails guides on ActiveJob: http://guides.rubyonrails.org/active_job_basics.html#enqueue-the-job
当然,您可以在一周内将ActiveJob排队。在作业的实施中,如果用户尚未注册,则有条件地发送电子邮件。请参阅ActiveJob上的Rails指南:http://guides.rubyonrails.org/active_job_basics.html#enqueue-the-job
Example:
例:
# Enqueue a job to be performed 1 week from now.
UserConfirmationJob.set(wait: 1.week).perform_later(user)
#2
0
Can you do it this way:
你能这样做吗:
- User gives the email.
- 用户发送电子邮件。
- You allow him to download.
- 你允许他下载。
- Every day you run a script to check that whether the user who gave his email 7 days ago has signed up or not.
- 您每天都会运行一个脚本来检查7天前发送电子邮件的用户是否已注册。
- And you send him an email if he hasn't signed up.
- 如果他还没有注册,你就给他发电子邮件。