开发者

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

Unable to send mail in rails 3. showing following message in browser.

Unknown action

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

Here is the code I wrote.

  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
    } 

Here is the log messages

AbstractControll开发者_JS百科er::ActionNotFound (The action 'method' could not be found for ActionMailer::Base):

app/mailers/notifier.rb:1:in <top (required)>'

app/controllers/users_controller.rb:17:in create'

Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb within rescues/layout (0.0ms)


It's

config.action_mailer.delivery_method

not

config.action_mailer.deliver_method

.

I happened to make the same typo in my configuration today.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜