2012-02-13 11 views
5

मैं ActionMailer उपयोग करने के लिए मुझे सूचित करने के लिए जब एक नई टिप्पणी पोस्ट किया गया है कोशिश कर रहा हूँ, लेकिन मैं त्रुटि प्राप्त हो रही:रेल 3 कार्रवाई मेलर अप्रारंभीकृत निरंतर

uninitialized constant CommentsController::CommentMailer 

टिप्पणी मेरी डेटाबेस में जोड़ा जाता है और हो सकता है देखी। मैं भी उपयोग कर रहा हूं और इसका ईमेल फ़ंक्शन ठीक काम कर रहा है।

मेरे टिप्पणी मेलर:

class CommentMailer < ActionMailer::Base 
    def newcomment(comment) 
    mail(:to => "[email protected]", :subject => "New Comment") 
    end 
end 

और मेरे नियंत्रक अनुभाग:

def create 
    @comment = Comment.new(params[:comment]) 
    @comment.user_id = current_user.id 

respond_to do |format| 
    if @comment.save 
    CommentMailer.newcomment(@comment).deliver 
    format.html { redirect_to @comment, notice: 'Comment was successfully created!' } 
    format.json { render json: @comment, status: :created, location: @comment } 
    else 
    format.html { render action: "new" } 
    format.json { render json: @comment.errors, status: :unprocessable_entity } 
    end 
end 
end 
+3

आपका त्रुटि संदेश "टिप्पणियां मेलर" कहता है जबकि आपका कोड टिप्पणीमेलर कहता है। क्या इस कोड से निश्चित रूप से त्रुटि आ रही है? क्या आप उस रेखा को इंगित कर सकते हैं जहां त्रुटि स्टैकट्रैक से आ रही है? – Shadwell

+0

क्षमा करें, जब मैंने अपने प्रश्न पूछा तो देर हो चुकी थी। यह "टिप्पणी मेलर" नहीं है "टिप्पणियाँमेलर" नहीं " – Steve

उत्तर

3

ठीक मेरा बुरा है, मैं के बाद मैं मेलर जोड़ा मेरी रेल अनुप्रयोग फिर से आरंभ किया था। यह ठीक काम कर रहा है

13

यह भी हो सकता है यदि आप अपनी मेलर फ़ाइल को गलत नाम देते हैं। UserMailer.rb टूट जाएगा जबकि user_mailer.rb अपेक्षित है।

संबंधित मुद्दे