【发布时间】:2020-01-09 23:52:56
【问题描述】:
我正在尝试在我的 rails 应用程序上获取一些 .js,但我遇到了 1 个问题。
已经有一个相同的问题,但答案对我也不好。
class CommentsController < ApplicationController
def create
@article = Article.find(params[:article_id])
@comment = @article.comments.create(params[:comment].permit(:name, :body))
@comment.name = current_user.email
respond_to do |format|
if @comment.save
format.js
redirect_to article_path(@article)
else
end
end
end
def destroy
@article = Article.find(params[:article_id])
@comment = @article.comments.find(params[:id])
@comment.destroy
redirect_to article_path(@article)
end
end
还有Create.js.erb文件
$('#forma2 table').append("<%= j render @comment %>")
来自终端的错误
Redirected to http://localhost:3000/articles/90
Completed 406 Not Acceptable in 27ms (ActiveRecord: 10.5ms)
ActionController::UnknownFormat (ActionController::UnknownFormat):
app/controllers/comments_controller.rb:7:in `create'
【问题讨论】:
标签: javascript ruby-on-rails ruby forms