以下表格旨在生成 XHR 响应
<% articlediscounts_for_article = @articlediscounts.where(article_id: article.id).first %>
<%= form_with(scope: articlediscounts_for_article, url: user_discount_users_path, local: false, method: :post) do |form| %>
行动过程
Processing by UsersController#user_discount as JS
并生成预期的结果,但在渲染过程中失败,抱怨(带有初始堆栈)
ActionController::UnknownFormat (UsersController#user_discount is missing a template for this request format and variant.
request.formats: ["text/javascript", "*/*"]
request.variant: []):
actionpack (6.1.3.2) lib/action_controller/metal/implicit_render.rb:42:in `default_render'
actionpack (6.1.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (6.1.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (6.1.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
然而,该模板显然存在于正确的路径中(其相应的部分也存在于目录中),如下所示:
这是令人困惑的,因为警告信息与现实背道而驰。想到的唯一假设是一些与变体或变体问题相form_with
结合的处理scope
这里有什么错误?