Tôi đang cố gắng sử dụng ActionMailer để thông báo cho tôi khi có bình luận mới đã được đăng nhưng tôi tiếp tục nhận được lỗi:Rails 3 Action Mailer uninitialized liên tục
uninitialized constant CommentsController::CommentMailer
Các bình luận được thêm vào cơ sở dữ liệu của tôi và có thể đã xem. Tôi cũng đang sử dụng thiết lập và các chức năng email của nó đang hoạt động tốt.
My comment bưu phẩm:
class CommentMailer < ActionMailer::Base
def newcomment(comment)
mail(:to => "[email protected]", :subject => "New Comment")
end
end
và phần điều khiển của tôi:
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
Thông báo lỗi của bạn cho biết "CommentsMailer" có chữ s trong khi mã của bạn cho biết CommentMailer. Lỗi chắc chắn đến từ mã này phải không? Bạn có thể xác định dòng nơi lỗi xuất phát từ stacktrace không? – Shadwell
Xin lỗi đã đến muộn khi tôi hỏi câu hỏi của tôi. nó là "CommentMailer" Không phải "CommentsMailer" no "s" – Steve