2011-03-18 68 views
3

无法使用rails 3发送邮件3.在浏览器中显示以下消息。Rails 3“无法找到ActionMailer :: Base的动作'方法'

Unknown action 

The action 'method' could not be found for ActionMailer::Base 

这是我写的代码。

  1. Notifier.rb

 
class Notifier < ActionMailer::Base 
    default :from => "[email protected]" 
    default_url_options[:host] = "localhost.com:3000"

def welcome_email(user)
@user_email = user @url = root_url mail(:to => user.email, :subject => "Welcome to the site") end end

2.UsersController.rb

 
Notifier.welcome_email(@user).deliver 

  1. application.rb中

 
config.action_mailer.deliver_method = :smtp 
    config.action_mailer.smtp_settings = { 
     :address => "smtp.gmail.com", 
     :port => 587, 
     :domain => 'xxxxxxx.com', 
     :user_name => '[email protected]', 
     :password => 'xxxx', 
     :authentication => 'plain', 
     :enable_starttls_auto => true 
    } 

这里是日志消息

一个AbstractController :: ActionNotFound (动作 '方法' 不能 找到的ActionMailer ::碱):
应用程序/邮寄者/通知。 RB:1:<top (required)>'
app/controllers/users_controller.rb:17:in
创建”

渲染 C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/unknown_actio n.erb 内救援/布局(0.0ms)

+0

请查看http://asciicasts.com/episodes/206-action-mailer-in-rails-3。它对我有好处 – 2011-03-18 10:17:34

回答

5

这是

config.action_mailer.delivery_method 

config.action_mailer.deliver_method 

我碰巧在今天的配置中出现了相同的错字。

+0

Arg - 它在这个红宝石文档中的拼写错误!邪恶 http://rubydoc.info/gems/amazon-ses-mailer/0.0.4/frames – Jeff 2012-06-06 23:17:09