5
我試圖使用的ActionMailer通知我,當一個新的評論已發佈,但我不斷收到錯誤:Rails 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
您的錯誤消息用s表示「CommentsMailer」,而您的代碼表示CommentMailer。這個錯誤肯定來自這個代碼嗎?你能找出錯誤來自堆棧跟蹤的行嗎? – Shadwell 2012-02-13 23:03:08
對不起,當我問我的問題時已經很晚了。它是「CommentMailer」而不是「CommentsMailer」否「s」 – Steve 2012-02-14 19:07:55