开发者

Using Rails and Devise, I want to send a welcome email on sign up.

开发者 https://www.devze.com 2023-01-20 04:21 出处:网络
How can I send a welcoming email to the user when they sign up? I\'m using the Devise gem for开发者_JS百科 authentication. SMTP is already set up. I just need to understand how to extend devise to sen

How can I send a welcoming email to the user when they sign up? I'm using the Devise gem for开发者_JS百科 authentication. SMTP is already set up. I just need to understand how to extend devise to send emails.

NOTE - this is not confirmation email!

UPD Solution:

class User < ActiveRecord::Base
  after_create :send_welcome_email 

  private

    def send_welcome_email
      UserMailer.deliver_welcome_email(self)
    end
end


Add a callback (after_create ) in the model or observer to send the email using normal mailer methods.


FYI, in Rails 3 it's:

class User < ActiveRecord::Base
  after_create :send_welcome_email 

  private

    def send_welcome_email
      UserMailer.welcome_email(self).deliver
    end 
end
0

精彩评论

暂无评论...
验证码 换一张
取 消