2013-06-19 1 views
0

안녕하세요이 가이드 다음 연락처 양식을 구현하기 위해 노력하고 있어요 : 내가 구글 애플 리케이션 있지만 따라 1and1의 SMTP를 사용하고 있지 않다 Contact form in Rails 3문의 양식 초기화되지 않은 상수 contactcontroller

합니다.

내가 양식을 전송하려고 할 때 내가 오류가

Processing by ContactController#create as HTML 
Parameters: {"utf8"=>"✓",  
"authenticity_token"=>"N48ORAhmDqTO7X2wsRlslMJ3l+v=", "message"=>{"name"=>"Patrick", "email"=>"[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 당신은 notification_mailer.rb

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 
+0

서버를 다시 시작 했습니까? –

+0

컨트롤러 동작 코드를 붙여 주실 수 있습니까? –

+0

@ Michael Szyndel 편집 된 질문 – Patrick

답변

2

-class NotificationMailer < ActionMailer::Base

변화를이 (제거들)

NotificationsMailer.new_message(@message).deliver 

으로210
+0

오타가 보지 못했지만 지금은이 질문에서 오류가 발생했습니다. http://stackoverflow.com/questions/14051056/rails-3-2-8-actionmailer-stack-level-too-deep-plus-uninitialized-constant-mail – Patrick

+1

새로운 문제를 발견 한 경우 새로운 질문을 만들 수 있습니다. 이 질문에 대한 답변을 수락하거나 솔루션을 게시하십시오. –