You have notification_mailer.rb
- class NotificationMailer < ActionMailer::Base
change this (remove s)
NotificationsMailer.new_message(@message).deliver
To
NotificationMailer.new_message(@message).deliver
Pergunta
Hello I am trying to implement a contact form following this guide: Contact form in Rails 3
I am not using google apps but 1and1's smtp.
The error I get when I attempt to send the form is
Processing by ContactController#create as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"N48ORAhmDqTO7X2wsRlslMJ3l+v=", "message"=>{"name"=>"Patrick", "email"=>"patrick@yahoo.com", "subject"=>"Hello", "body"=>"Hello ME"}, "commit"=>"Send"}
NameError (uninitialized constant ContactController::NotificationsMailer):
app/controllers/contact_controller.rb:11:in `create'
After some attempts at tweaking, I ended up just copying and pasting the code from the guide. Still have a problem.
class ContactController < ApplicationController
def new
@message = Message.new
end
def create
@message = Message.new(params[:message])
if @message.valid?
NotificationsMailer.new_message(@message).deliver
redirect_to(root_path, :notice => "Message was successfully sent.")
else
flash.now.alert = "Please fill all fields."
render :new
end
end
end
NotificationMailer
class NotificationMailer < ActionMailer::Base
default from: "noreply@misawahousing.com"
default to: "info@misawahousing.com"
def new_message(message)
@message = message
mail(subject: "[misawahousing.com] #{message.subject}")
end
end
Solução
You have notification_mailer.rb
- class NotificationMailer < ActionMailer::Base
change this (remove s)
NotificationsMailer.new_message(@message).deliver
To
NotificationMailer.new_message(@message).deliver