Rails 缺少部分 *.js.erb

Rails missing partial *.js.erb

我试图在不重新加载整个页面的情况下通知用户错误,但我收到错误消息“AnswersController#create 缺少此请求格式和变体的模板”

create.js.erb

$('.answer-errors').html("<%= render 'shared/errors', resource: @answer %>");

AnswersController#create

def create
  @answer = question.answers.build(answer_params)

  if @answer.save
    redirect_to question, notice: t('.success')
  end
end

app/views/shared/_errors.html.slim 存在。

app/views/answers/_form.html.slim - 这是新答案的表格

= form_with model: [question, answer], class: 'form-answer hide' do |form|
 = form.label :body
 = form.text_area :body
 = form.submit 'Save'

控制台日志。我在这里看到“由 AnswersController 处理#create as HTML”,但它应该是“..as js”吗?

Started POST "/questions/3/answers" for 127.0.0.1 at 2021-08-23     21:19:08 +0300
Processing by AnswersController#create as HTML
  Parameters: {"authenticity_token"=>"[FILTERED]", "answer"=>    {"body"=>""}, "commit"=>"Save", "question_id"=>"3"}
  User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" =  ORDER BY "users"."id" ASC LIMIT   [["id", 1], ["LIMIT", 1]]
  Question Load (0.7ms)  SELECT "questions".* FROM "questions" WHERE "questions"."id" =  LIMIT   [["id", 3], ["LIMIT", 1]]
  ↳ app/controllers/answers_controller.rb:27:in `question'
Completed 406 Not Acceptable in 8ms (ActiveRecord: 1.3ms | Allocations: 4424)

ActionController::UnknownFormat (AnswersController#create is missing a template for this request format and variant.

request.formats: ["text/html"]
request.variant: []):

哪里会出问题?

非常感谢@max link 的指导。

form_with model: [question, answer], class: 'form-answer hide', local: false do..

这工作正常,但我仍然不明白为什么 remote: true 与 local: false 不一样。这对我来说是违反直觉的,任何提示都会令人愉快