简体   繁体   English

发送自定义值以设计邮件程序

[英]sending custom values to devise mailer

I've got a multi-tenant app and I'm trying to send some information about the current tenant along with with the devise mailer so I can customize some of the text. 我有一个多租户应用程序,我正尝试发送一些有关当前租户的信息以及devise邮件程序,以便我可以自定义一些文本。

Anyone know how I can send my current_tenant object too? 有人知道我也可以发送current_tenant对象吗? I've seen a few methods where you overwrite the mailer in the User model, but current_tenant is only available in the controller. 我已经看到了几种方法可以覆盖User模型中的邮件程序,但是current_tenant仅在控制器中可用。

def create
  self.resource = resource_class.send_reset_password_instructions(resource_params)
end

Ideally, I'd like to do something like 理想情况下,我想做类似的事情

def create
  self.resource = resource_class.send_reset_password_instructions(resource_params, current_tenant)
end

and be able to access my current_tenant object inside the email. 并能够访问电子邮件中的current_tenant对象。

Thanks in advance 提前致谢

Looks like this will be in devise at some point but in the meantime I found a fork that allows for somebody to pass mailer_params into the message. 看起来这是在某个时候设计的,但是与此同时,我发现了一个分叉,允许某人将mailer_params传递到消息中。 I tried it and it works. 我试过了,它有效。 Here's the github discussion in case anyone else is interested: 如果有人感兴趣,这里是github讨论:

https://github.com/plataformatec/devise/pull/2207 https://github.com/plataformatec/devise/pull/2207

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM