Devise Invitable:可选发送电子邮件 [英] Devise Invitable : Optionally Send Email

查看:227
本文介绍了Devise Invitable:可选发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设计邀请中,您可以通过执行以下方式邀请新用户:

in devise invitable, you can invite a new user by performing:

User.invite!(:email => "new_user@example.com", :name => "John Doe")

喜欢做是(有时)防止设计邀请发送电子邮件。我在图书馆中找到以下代码:

What I would like to do is (sometimes) prevent devise invitable from sending out an email. I found the following code in the library:

def invite!
        if new_record? || invited?
          self.skip_confirmation! if self.new_record? && self.respond_to?(:skip_confirmation!)
          generate_invitation_token if self.invitation_token.nil?
          self.invitation_sent_at = Time.now.utc
          save(:validate => false)
          ::Devise.mailer.invitation_instructions(self).deliver
        end
      end

有关如何最佳更新以便在最后一行不发送电子邮件的任何想法?我不熟悉::

Any ideas on how to best update that to not send out the email on the last line? I'm not familiar with the ::

谢谢

推荐答案

您可以使用:

User.invite!(:email => "new_user@example.com", :name => "John Doe") do |u|
  u.skip_invitation = true
end

User.invite!(:email => "new_user@example.com", :name => "John Doe", :skip_invitation => true)

这将跳过邀请电子邮件。

this will skip invitation email.

这篇关于Devise Invitable:可选发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆