新的 Rails 和现在使用 Windows,我有用户插入姓名、日期和电子邮件的网页。根据他输入的日期,我想向他发送电子邮件(如果@dop.date=date.now-7.days then send email
)。我怎么能实现它?我希望系统获取用户日期并检查用户是否插入日期,并且日期已经 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
这是我的模型: class Dop < ActiveRecord::Base attr_accessible :date,:mail,:name validates_presence_of:name validates_presence_of:mail validates_uniqueness_of:mail
结尾