Sto cercando di utilizzare ActionMailer per notificare me quando una nuova foto è stata pubblicata, ma continuo a ricevere l'errore:Rails 3 Azione Mailer non inizializzata costante
uninitialized constant CommentsController::CommentMailer
Il commento viene aggiunto al mio database e può essere consultati. Sto anche usando Devise e le sue funzioni di posta elettronica stanno funzionando bene.
Il mio commento mailer:
class CommentMailer < ActionMailer::Base
def newcomment(comment)
mail(:to => "[email protected]", :subject => "New Comment")
end
end
e la mia sezione di controllo:
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
Il tuo messaggio di errore dice "CommentiMailer" con un s mentre il tuo codice dice CommentMailer. L'errore proviene sicuramente da questo codice? Puoi individuare la linea in cui l'errore proviene dallo stacktrace? – Shadwell
Scusa era tardi quando ho fatto la mia domanda. è "CommentMailer" Not "CommentiMailer" no "s" – Steve