Привет Я пытаюсь реализовать контактную форму по этой направляющей: Contact form in Rails 3форма контакта неинициализированным постоянная contactcontroller
Я не использую Google Apps, но SMTP 1and1 в.
Я получаю ошибку, когда я пытаюсь отправить форму в
Processing by ContactController#create as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"N48ORAhmDqTO7X2wsRlslMJ3l+v=", "message"=>{"name"=>"Patrick", "email"=>"p[email protected]", "subject"=>"Hello", "body"=>"Hello ME"}, "commit"=>"Send"}
NameError (uninitialized constant ContactController::NotificationsMailer):
app/controllers/contact_controller.rb:11:in `create'
После нескольких попыток настройки, я в конечном итоге просто скопировать и вставить код из руководства. Все еще есть проблема.
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: "[email protected]"
default to: "[email protected]"
def new_message(message)
@message = message
mail(subject: "[misawahousing.com] #{message.subject}")
end
end
Перезагрузите сервер? –
Не могли бы вы вставить код действия контроллера, пожалуйста? –
@ Michael Szyndel Отредактировано originai question – Patrick