gpt4 book ai didi

ruby-on-rails - 设计发送欢迎电子邮件

转载 作者:行者123 更新时间:2023-12-05 08:42:57 24 4
gpt4 key购买 nike

我有一个名为members 的设计模型,我正在使用可确认的设计。确认后,我想向用户发送一封欢迎邮件

class Member < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable

# Methods

# Override devise confirm! message
def confirm!
welcome_email
super
end

# Private Methods
private

def welcome_email
MemberMailer.welcome_email(self).deliver
end

end

我的 MemberMailer 位于 mailers/brands/member_mailer.rb

class Brands::MemberMailer < ApplicationMailer

# Send Welcome Email once Member confirms the account
def welcome_email(member)
@member = member
mail(to: @member.email, subject: "Welcome to Skreem! Now you Rock!")
end
end

但是在通过邮件链接确认后,confirm! 没有被覆盖,而且我没有收到任何错误或电子邮件。

最佳答案

将此添加到您的 Member 模型:

def after_confirmation
welcome_email
end

更多信息请查看after_confirmation

@Pavan 感谢您指出这一点。

您的welcome_email 应该是:

def welcome_email
Brands::MemberMailer.welcome_email(self).deliver
end

关于ruby-on-rails - 设计发送欢迎电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36597212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com