我正在尝试从我的应用程序发送电子邮件。当我不使用观察者时,会发送电子邮件。当我使用观察者时,我收到以下错误:
undefined local variable or method ` UserMailer' for #<UserObserver:0x7f5730c07400>
这是我的 UserMailer
class UserMailer < ActionMailer::Base
default :from => "from@me.com"
def welcome_email(user)
@user = user
@url = "website.com/home"
mail(:to => user.email, :subject => "Welcome to My Awesome Site")
end
end
观察者代码
require "#{Rails.root}/app/mailers/user_mailer.rb"
class UserObserver < ActiveRecord::Observer
observe :user
def after_save(user)
UserMailer.welcome_email(user).deliver
end
end
任何帮助将不胜感激。我是铁轨上的红宝石。TIA