Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.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 按钮_to with remote::true以重定向结束_Ruby On Rails_Ruby_Ajax_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 按钮_to with remote::true以重定向结束

Ruby on rails 按钮_to with remote::true以重定向结束,ruby-on-rails,ruby,ajax,ruby-on-rails-4,Ruby On Rails,Ruby,Ajax,Ruby On Rails 4,我正在尝试为表单创建一个按钮,允许用户保存输入的数据,而无需重定向/重新加载或其他任何操作 我在我的表单部分中添加了一个按钮,如下所示: <%= button_to "Update", incorporation_path(@incorporation), method: :post, remote: true %> 这确实保存了数据,但提交了带有重定向和all的表单 在向updatecontroller方法添加一个render:nothing=>true时,当我单击按钮时,我

我正在尝试为表单创建一个按钮,允许用户保存输入的数据,而无需重定向/重新加载或其他任何操作

我在我的表单部分中添加了一个
按钮,如下所示:

<%= button_to "Update", incorporation_path(@incorporation), method: :post, remote: true %>

这确实保存了数据,但提交了带有重定向和all的表单

在向updatecontroller方法添加一个
render:nothing=>true
时,当我单击按钮时,我只看到一个空白页面。这尤其令人惊讶,因为我认为
remote:true
行可以防止这种情况

有什么事吗


感谢您的任何想法

更新

你说的是表格!您是否已为
设置了
表单_上的
远程:true
?因为这就是异步提交表单的方式

原始答案

remote:true
是的一部分。顾名思义,这种方法是不显眼的,如果JS被停用或库未加载,这种方法将不起作用。因此,请确保脚本文件中包含以下行:

//= require jquery
//= require jquery_ujs

remote:true
是否适用于其他任何地方,但不适用于这里?@Yan_Foto fair question;是的,没有看到元素上的
数据远程:true
属性吗?请提供表单的一个片段,并查看下面的答案!对你的更新:啊,我想我没有。我查一下再给你回电话。非常感谢。关于您的原件:是的,两者都在there@neanderslob很高兴我能帮忙。