Rails 3:脚手架销毁动作重定向以显示动作
我创建了一个简单的脚手架,问题是当我尝试删除一条记录时单击 destroy Rails 重定向到显示操作,这是我生成脚手架时自动生成的链接的代码:
<%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %>
出了什么问题?
i created a simple scaffold, the problem is that when i try to delete a record click destroy rails redirect to the show action, this is the code of the link generated automatically when i generate the scaffold:
<%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %>
what's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将
rails.js
包含在您的应用程序布局中,因为此链接需要 JS 使用正确的 HTTP 方法。另请确保您的布局中有csrf_meta_tag
。You need to have
rails.js
included in your application layout, as this link require JS to use the correct HTTP method. Also make sure you have thecsrf_meta_tag
in your layout.检查您的
application.js
是否有//= require jquery_ujs
Check if your
application.js
has//= require jquery_ujs
在
application.js
中添加这段代码Add in
application.js
this code