ActionMailer什么都不做,设置正确

时间:2013-02-14 04:01:44

标签: ruby-on-rails-3 actionmailer

development.rb我有这些ActionMailer设置:

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
  address: "smtp.gmail.com",
  port: 587,
  domain: "gmail.com",
  authentication: "plain",
  enable_starttls_auto: true,
  user_name: "username@gmail.com",
  password: "password"
}

notifier.rb(我的邮件程序)中,我有以下定义:

def user_email(user)
  @user = User.find(user)
  mail(:to => user.email, :subject => "Welcome to me.")
end

def test_email
  mail(:to => "here@there.com", :subject => "Test mail", :body => "Ain't I shapely?")
end

在控制台中运行Notifier.test_email.deliver会给我:wrong number of arguments (0 for 1)

在控制台中运行Notifier.user_email(2).deliver会给我:undefined method 'user_email' for Notifier:Class

我错过了一些完全明显的东西吗? Gmail设置都是正确的,但显然问题出在此之前。

1 个答案:

答案 0 :(得分:0)

重新启动服务器修复它。无义。