2017-10-18 96 views
0

我需要发送不同的确认电子邮件,同时使用设计。发送不同的确认电子邮件与设计

因此,当用户从子域注册时,他们会收到不同的确认电子邮件,并且当用户从根域注册时,他们会收到不同的电子邮件。

我该如何做到这一点?

编辑:

我创建MyDeviceMailer

class MyDeviseMailer < Devise::Mailer 
    layout 'mailers' 

    # To make sure that your mailer uses the devise views 
    default template_path: 'devise/mailer' 

def confirmation_instructions(record, token, options={}) 
    # Use different e-mail templates for signup e-mail confirmation 
    # and for when a user changes e-mail address. 
    if request.subdomain? 
    options[:template_name] = 'confirmation_instructions_sub' 
    else 
    options[:template_name] = 'confirmation_instructions' 
    end 
    super 
    end 
end 

,在我devise.rb文件我加

config.mailer = 'MyDeviseMailer'

+1

您能告诉我们您已经试过了吗? – siegy22

+0

添加了我到目前为止所做的 –

回答

0

好了,我终于解决了这个问题。而不是陷入所有这些复杂性,只需更换您的确认链接

<%= link_to 'Confirm my account', user_confirmation_url(confirmation_token: @token, subdomain: Apartment::Tenant.current) %> 
相关问题