我正在构建一个允许用户插入信息名称、日期和电子邮件的系统。我希望系统在用户插入后每 7 天自动向其用户发送电子邮件。
这是我的邮件
class UserMailer < ActionMailer::Base
default from: "from@example.com"
def welcome_email(dop)
@dop = dop
@url = "http://example.com/login"
mail(:to => dop.mail, :subject => "Welcome to My Awesome Site")
end
end
这是控制器:
def create
@dop = Dop.new(params[:dop])
respond_to do |format|
if @dop.save
UserMailer.welcome_email(@dop).deliver
format.html { redirect_to @dop, notice: 'Dop was successfully created.' }
format.json { render json: @dop, status: :created, location: @dop }
else
format.html { render action: "new" }
format.json { render json: @dop.errors, status: :unprocessable_entity }
end
end
end