簡體   English   中英

Rails 3“無法找到ActionMailer :: Base的動作'方法'

[英]Rails 3 “The action 'method' could not be found for ActionMailer::Base”

無法在rails 3中發送郵件。在瀏覽器中顯示以下消息。

Unknown action

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

這是我寫的代碼。

  1. Notifier.rb


class Notifier < ActionMailer::Base 
  default :from => "xxxxx@gmail.com"
  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 => 'xxxx@gmail.com',
      :password => 'xxxx',
      :authentication => 'plain',
      :enable_starttls_auto => true
    } 

這是日志消息

AbstractController :: ActionNotFound(無法在ActionMailer :: Base中找到操作'method'):
app / mailers / notifier.rb:1:in <top (required)>'
app/controllers/users_controller.rb:17:in
<top (required)>'
app/controllers/users_controller.rb:17:in
<top (required)>'
app/controllers/users_controller.rb:17:in
create'

在救援/布局中呈現C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb(0.0ms)

它的

config.action_mailer.delivery_method

config.action_mailer.deliver_method

我今天在配置中遇到了相同的拼寫錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM