Ste*_*eve 5 ruby-on-rails actionmailer
我正在尝试使用actionmailer在发布新评论时通知我,但我一直收到错误消息:
uninitialized constant CommentsController::CommentMailer
Run Code Online (Sandbox Code Playgroud)
评论已添加到我的数据库中,可以查看.我也在使用设计,它的电子邮件功能正常.
我的评论邮件:
class CommentMailer < ActionMailer::Base
def newcomment(comment)
mail(:to => "admin@example.com", :subject => "New Comment")
end
end
Run Code Online (Sandbox Code Playgroud)
和我的控制器部分:
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7806 次 |
| 最近记录: |