Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails AbstractController::DoubleRenderError_Ruby On Rails_Ruby_Model View Controller - Fatal编程技术网

Ruby on rails AbstractController::DoubleRenderError

Ruby on rails AbstractController::DoubleRenderError,ruby-on-rails,ruby,model-view-controller,Ruby On Rails,Ruby,Model View Controller,当我提交此文件时: <%= simple_form_for(@missed_date, url: habit_level_missed_dates_path({ habit_id: @habit, level_id: @habit.current_habit_level.id }), remote: request.xhr?, html: { data: { modal: true } }) do |f| %> 这是因为错误: AbstractController::DoubleR

当我提交此文件时:

<%= simple_form_for(@missed_date, url: habit_level_missed_dates_path({ habit_id: @habit, level_id: @habit.current_habit_level.id }), remote: request.xhr?, html: { data: { modal: true } }) do |f| %>
这是因为错误:

AbstractController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".):
  app/controllers/missed_dates_controller.rb:26:in `create'
现在我知道原因了,这是因为我有一个格式为_for
url:attribute\u level\u missed\u dates\u path({attribute\u id:@attribute,level\u id:@attribute.current\u attribute\u level.id})
,但我需要它,至少我认为是这样,在创建时传递这些属性

我如何修改此设置,以便当用户在
@missed_date
表单中单击submit时,id的通行证会被重定向回
根url


我按照本教程学习了模态逻辑:。

您正在调用
head
,它只返回一个header响应。调用
head
相当于渲染块中的返回语句。看起来您正在调用
head
,然后继续渲染更多代码,因此出现了双重渲染错误。您可能根本不需要该行,因为默认的响应代码是200

非常感谢你!太好了。
AbstractController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".):
  app/controllers/missed_dates_controller.rb:26:in `create'