Rails 3 "Action Method" not found for ActionMailer :: Base "

Unable to send mail to rails 3. show the following message in a browser.

Unknown action

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

Here is the code I wrote.

  • 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
  • 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 are the log messages

AbstractController :: ActionNotFound (The "method" of the action cannot be found for ActionMailer :: Base):
app / mailers / notifier.rb: 1: in create '<top (required)>'
app/controllers/users_controller.rb:17:in

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

+3
1

config.action_mailer.delivery_method

config.action_mailer.deliver_method

.

​​ .

+5

All Articles