Rails。自定义表单字段参数时发送创建通知
Rails. Send create notification when custom form field param
如果填写了自定义表单字段,如何发送电子邮件?
def create
@act = Act.new(act_params)
respond_to do |format|
if @act.save
ModelMailer.new_act_notification(@act).deliver_later if customer_id == '617'
format.html { redirect_to @act, notice: 'Act was successfully created.' }
else
format.html { render action: "new" }
end
end
end
除非您设置变量 customer_id,否则这将不起作用。我想你想要的是这个:
ModelMailer.new_act_notification(@act).deliver_later if @act.customer_id == 617
我假设当你说'custom form field param'时,你指的是@act
中对象的customer_id参数。
如果填写了自定义表单字段,如何发送电子邮件?
def create
@act = Act.new(act_params)
respond_to do |format|
if @act.save
ModelMailer.new_act_notification(@act).deliver_later if customer_id == '617'
format.html { redirect_to @act, notice: 'Act was successfully created.' }
else
format.html { render action: "new" }
end
end
end
除非您设置变量 customer_id,否则这将不起作用。我想你想要的是这个:
ModelMailer.new_act_notification(@act).deliver_later if @act.customer_id == 617
我假设当你说'custom form field param'时,你指的是@act
中对象的customer_id参数。